aidsorb.visualize#
Helper functions for visualizing input representations.
Tip
To visualize point clouds or voxels using the CLI:
$ aidsorb visualize path/to/pcd_or_voxels.npy
To visualize a structure you can use ase:
from ase.io import read from ase.visualize import view atoms = read('path/to/file') view(atoms)
- aidsorb.visualize.draw_from_file(filename, render=True, **kwargs)[source]#
Visualize point cloud or voxels from a file.
- Parameters:
filename (str) – Absolute or relative path to a
.npy.render (bool, default=True) – Whether to render the data with
plotly.io.renderers.defaultor return the figure object.**kwargs – Valid keyword arguments for
draw_pcd()ordraw_voxels().
- Return type:
plotly.graph_objects.Figure or None
- 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-like 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 onscheme. IfFalse, assume a generic point cloud and size each point based onsize.scheme ({'jmol', 'cpk'}, default='cpk') – Takes effect only if
molecular=Trueandfeature_to_color=None.size (float, default=2.) – Controls the size of points.
feature_to_color (tuple, optional) – Tuple of the form
(index, label), whereindexis the index of the feature to be colored andlabelis the text label for the colorbar.colorscale (str, optional) – No effect if
feature_to_color=None. For available options, see colorscale.
- Return type:
Examples
>>> pcd = np.random.randn(10, 3) >>> fig = draw_pcd(pcd, molecular=False, feature_to_color=(0, 'x coord'), colorscale='viridis')
- aidsorb.visualize.draw_voxels(voxels, isomin=-1000.0, isomax=1000.0, opacity=0.15, surface_count=5, colorscale=None, label='Energy / K')[source]#
Visualize voxels with Plotly.
Todo
Add support for multi-channel voxels.
- Parameters:
voxels (array-like of shape (D, H, W))
isomin (float, default=-1000) – Minimum value of the displayed range.
isomax (float, default=1000) – Maximum value of the displayed range.
opacity (float, default=0.15) – Opacity of the volume rendering.
surface_count (int, default=5) – Number of isosurfaces to approximate the volume.
colorscale (str, optional) – For available options, see colorscale.
label (str, default='Energy / K') – Text label for the colorbar.
- Return type:
Notes
Default parameter values are chosen to provide a reasonable visualization for energy voxels.
Examples
>>> voxels = np.random.randn(3, 3, 3) >>> fig = draw_voxels(voxels, colorscale='viridis')
- 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='cpk')
- 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)