ase_notebook.viewer module

A module for creating visualisations of a structure.

class ase_notebook.viewer.AseView(config: Union[None, ase_notebook.configuration.ViewConfig] = None, **kwargs)[source]

Bases: object

Class for visualising ase.Atoms or pymatgen.Structure.

_add_element_properties(atoms, element_groups, bond_thickness, lighten_by_depth=True)[source]

Add initial properties to the element groups.

_initialise_elements(atoms, center_in_uc=False, repeat_uc=(1, 1, 1))[source]

Prepare visualisation elements, in a backend agnostic manner.

add_miller_plane(h, k, l, *, color='blue', stroke_color=None, stroke_width=1, fill_opacity=0.5, stroke_opacity=0.9, reset=False)[source]

Add a miller plane to the config.

Parameters
  • h (int or float) –

  • k (int or float) –

  • l (int or float) –

  • color (str) – color of plane

  • stroke_color (str or None) – color of outline (if None, color is used)

  • stroke_width (int) – width of outline

  • reset (bool) – if True, remove any previously set miller planes

property config

Return the visualisation configuration.

copy()[source]

Return a copy of this instance.

get_atom_colors(atoms)[source]

Return mapping of atom index to (hex) color.

get_atom_labels(atoms)[source]

Return mapping of atom index to text label.

get_atom_radii(atoms)[source]

Return mapping of atom index to sphere radii.

get_config_as_dict()[source]

Return the configuration as a JSONable dictionary.

get_element_colors()[source]

Return mapping of element atomic number to (hex) color.

get_element_radii()[source]

Return mapping of element atomic number to atom radii.

get_input_as_dict(atoms, **kwargs)[source]

Return the configuration, atoms and kwargs as a JSONable dictionary.

launch_gui_subprocess(atoms, center_in_uc=False, repeat_uc=(1, 1, 1), test_init=2)[source]

Launch a GUI to view the atoms or structure, in a (non-blocking) subprocess.

We encode all the data into a json object, then parse this to a console executable via stdin.

Parameters

test_init – wait for a x seconds, then test whether the process initialized without error.

make_gui(atoms, center_in_uc=False, repeat_uc=(1, 1, 1), bring_to_top=True, launch=True)[source]

Launch a (blocking) GUI to view the atoms or structure.

make_render(atoms, center_in_uc=False, repeat_uc=(1, 1, 1), reuse_objects=True, use_atom_arrays=False, use_label_arrays=True, create_gui=True)[source]

Create a pythreejs render of the atoms or structure.

make_svg(atoms, center_in_uc=False, repeat_uc=(1, 1, 1))[source]

Create an SVG of the atoms or structure.

static values_to_colors(values, cmap, cmap_range=(None, None))[source]

Map hex colors, to a list of values.

ase_notebook.viewer.launch_gui_exec(json_string=None)[source]

Launch a GUI, with a json string as input.

Parameters

json_string (str or None) – A json string containing all data required for running AseView.makegui. If None, the string is read from stdin.