aidsorb.visualize

Helper functions for visualizing point clouds.

Tip

To visualize a point cloud from the CLI:

$ aidsorb visualize path/to/structure_or_pcd  # Structure (.xyz, .cif, etc) or .npy

You can also visualize a structure with ase:

from ase.io import read
from ase.visualize import view

atoms = read('path/to/file')
view(atoms)
aidsorb.visualize.draw_pcd(pcd, molecular=True, scheme='cpk', size=2.0, feature_to_color=None, colorscale=None)[source]

Visualize point cloud with Plotly.

Parameters:
  • pcd (array of shape (N, 3+C))

  • molecular (bool, default=True) – If True, assume a molecular point cloud. In this case, each atom is sized as \(r_{\text{vdW}}^4\) and colorized based on scheme. If False, assume a generic point cloud and size each point based on size.

  • scheme ({'jmol', 'cpk'}, default='jmol') – Takes effect only if molecular=True and feature_to_color=None.

  • size (float, default=2.) – Controls the size of points.

  • feature_to_color (tuple, optional) – Tuple of the form (index, label), where index is the index of the feature to be colored and label is the text label for the colorbar.

  • colorscale (str, optional) – No effect if feature_to_color=None. For available options, see colorscale.

Return type:

plotly.graph_objects.Figure

Examples

>>> pcd = np.random.randn(10, 3)
>>> fig = draw_pcd(pcd, molecular=False, feature_to_color=(0, 'x coord'), colorscale='viridis')
aidsorb.visualize.draw_pcd_from_file(filename, render=True, **kwargs)[source]

Visualize point cloud from a file.

Parameters:
  • filename (str) – Absolute or relative path to a .npy or structure file.

  • render (bool, default=True) – Whether to render the point cloud with plotly.io.renderers.default or return the figure object.

  • **kwargs – Valid keyword arguments for draw_pcd().

Return type:

plotly.graph_objects.Figure or None

aidsorb.visualize.get_atom_colors(atomic_numbers, scheme='cpk')[source]

Convert atomic numbers to colors based on scheme.

Parameters:
  • atomic_numbers (array-like of shape (N,))

  • scheme ({'jmol', 'cpk'}, default='jmol')

Returns:

colors

Return type:

array of shape (N,)

aidsorb.visualize.get_atom_names(atomic_numbers)[source]

Convert atomic numbers to element names.

Parameters:

atomic_numbers (array-like of shape (N,))

Returns:

elements

Return type:

array of shape (N,)

Examples

>>> atomic_numbers = np.array([1, 2, 7])
>>> get_atom_names(atomic_numbers)
array(['Hydrogen', 'Helium', 'Nitrogen'], dtype=object)