sith.visualize package
Submodules
- class sith.visualize.ngl.EnergiesNGL(sith_info, idef='all', alignment=None, axis=False, background='#FFFFFF', **kwargs)[source]
Bases:
MoleculeNGLSet of tools to show a molecule and the distribution of energies in the different DOF.
- Parameters:
sith_info – sith object or sith.utilities.ReadSummary object
idef (int. Default='all') – number of the deformation to be analized. Default=None, that means, all the structures are displayed as a trajectory.
alignment (list. Default=None) – 3 indexes to fix the correspondig atoms in the xy plane. The first atom is placed in the negative side of the x axis, the second atom is placed in the positive side of the x axis, and the third atom is placed in the positive side of the y axis.
axis (bool) – add xyz axis
background (color) – background color. Default: ‘#ffc’
kwargs – kwargs of MoleculeNGL
- change_def(def_dict: dict, **kwargs) tuple[source]
This functions change the values stored in a dictionary and removes each one of the arguments from the kwargs.
- Parameters:
def_dict (dict) – dictionary with the default values.
kwargs – all the arguments you want to change.
- Returns:
(dict, dict) modified dictionary withe the default values and set of
kwargs without the used keys.
- energies_all_dof(**kwargs)[source]
Add all DOF with a color scale that represents the distribution of energy according to the JEDI method.
- Parameters:
kwargs – of internal method energies_some_dof.
- Return type:
(plt.figure) fig of energies_some_dof.
- energies_angles(**kwargs)[source]
Add the angles with a color scale that represents the distribution of energy according to the JEDI method.
- Parameters:
kwargs – of internal method energies_some_dof.
- Return type:
(plt.figure) fig of energies_some_dof.
- energies_bonds(**kwargs)[source]
Add the bonds with a color scale that represents the distribution of energy according to the JEDI method.
- Parameters:
kwargs – of internal method energies_some_dof.
- Return type:
(plt.figure) fig of energies_some_dof.
- energies_dihedrals(**kwargs)[source]
Add the dihedral angles with a color scale that represents the distribution of energy according to the JEDI method.
- Parameters:
kwargs – of internal method energies_some_dof.
- Return type:
(plt.figure) fig of energies_some_dof.
- energies_some_dof(dofs, **kwargs)[source]
Add the bonds with a color scale that represents the distribution of energy according to the JEDI method.
- Parameters:
dofs (list of tuples.) – list of degrees of freedom defined using 1-based indexing.
kwargs – optional kwargs of internal method change_def
- Return type:
(plt.figure) figure of the colorbar.
- show_bonds(**kwargs)[source]
Show the bonds in the molecule.
- Parameters:
show_dof (kwargs for)
- Return type:
(None)
Notes
The color is not related with the JEDI method. It could be changed with the kwarg color=rgb list.
- show_bonds_of_DOF(dof, unique=False, color=None)[source]
Show an specific dof.
- Parameters:
dof (int.) – index in sith object that corresponds to the dof you want to show.
unique (Bool. default False.. Default=False) – True if you want to remove all the other bonds and only keeping these ones.
color (list[3(int)]. default R G B for angles, distances, dihedrals.) – color that you want to use in this dof.
- Return type:
(list) Bonds in the system.
- show_dof(dofs, **kwargs)[source]
Show specific degrees of freedom.
- Parameters:
dofs (list of tuples.) – list of degrees of freedom defined using 1-based indexing.
add_dof (kwargs for)
- Return type:
(None)
Notes
The color is not related with the JEDI method. It could be changed with the kwarg color=rgb list.
- class sith.visualize.ngl.MoleculeNGL(atoms, alignment=None, axis=False, xsize: int = 500, ysize: int = 500, n=5)[source]
Bases:
objectSet of graphic tools to see the distribution of energies in the different degrees of freedom (lengths, angles, dihedrals). Wrap to NGLview.
- Parameters:
atoms (ase.Atoms) – Atoms object to be visualized
alignment (list[int]. Default=None) – list of three indexes corresponding to the indexes of the atoms in the xy plane. the first two atoms are set to the x axis.
axis (bool. Default=False) – Show xyz axis.
xsize (int. Default=500.) – Horizontal size of the visualization windows.
ysize (int. Default=500.) – Vertical size of the visualization windows.
- add_angle(atom1index, atom2index, atom3index, color=None, n=None)[source]
Add an angle to between three atoms: atom1, atom2 and atom3 - with the vertex in the atom2
- Parameters:
atom1index (int) – Indexes of the first atom that defines the angle.
atom2index (int) – Indexes of the second atom that defines the angle.
atom3index (int) – Indexes of the third atom that defines the angle.
color (color list. Default all gray([0.5, 0.5, 0.5])) – RGB triplet.
n (int. Default=internal defined n) – number of intermedia points to add in the arc of the angle.
- Return type:
(list) list of meshes forming the angle.
- add_arc(vertex, arcdots, color)[source]
Add an arc using triangles.
- Parameters:
vertex (array) – center of the arc
arcdots (list of arrays) – vectors that define the points of the arc. These vectors must be defined respect the vertex.
color (color format.) – color if the arc to be added
- Return type:
(list) list of meshes forming the arc.
- add_axis(length=1, radius=0.1)[source]
Add xyz axis.
- Parameters:
length (float. Default=1) – indicates the length of the axis in the visualization. Default=1
radius (float. Default=0.1) – thickness of the xyz axis
- Return type:
(dict) axis as dict with cylinder shapes of nglview.
- add_bond(atom1index, atom2index, color=None, radius=0.1)[source]
Add a bond between two atoms: atom1 and atom2
- Parameters:
atom1index (int) – Indexes of the atoms to be connected using 1-based indexing.
atom2index (int) – Indexes of the atoms to be connected using 1-based indexing.
color (list. Default=gray([0.5, 0.5, 0.5])) – RGB triplet.
radius (float. Default=0.1) – Radius of the bond.
- Return type:
(Vpython object) Cylinder representing the just added bond.
- add_bonds(atoms1indexes, atoms2indexes, colors=None, radii=None)[source]
Add a bond between each pair of atoms corresponding to two lists of atoms: atom1indexes and atom2indexes.
- Parameters:
atoms1indexes (int) – Indexes of the atoms to be connected using 1-based indexing.
atoms2indexes (int) – Indexes of the atoms to be connected using 1-based indexing.
colors (list of color lists. Default all gray([0.5, 0.5, 0.5])) – RGB triplets for each of the bonds. It can be one a triplet in case of just one color in all bonds.
radii (float or list of floats. Default 0.1) – radius of each bond.
- Return type:
(list) Bonds in the system
- add_dihedral(atom1index, atom2index, atom3index, atom4index, color=None, n=None)[source]
Add an dihedral angle between four atoms: atom1, atom2, atom3 and atom4 - with the vertex in the midle of the atom 2 and 3
- Parameters:
atom1index (int) – Indexes of the first atom that defines the angle.
atom2index (int) – Indexes of the second atom that defines the angle.
atom3index (int) – Indexes of the third atom that defines the angle.
atom4index (int) – Indexes of the fourth atom that defines the angle.
color (color list. Default all gray([0.5, 0.5, 0.5])) – RGB triplet.
n (int. Default 10) – number of intermedia points to add in the arc of the angle.
- Return type:
(list) All the displayed dihedral angles.
- add_dof(dof, color=None, **kwargs)[source]
Add the degree of freedom to the molecule image
- Parameters:
dof (tuple) – label of the degree of freedom using 1-based indexing.
color (color format. Default=[0.5, 0.5, 0.5]) – Color of the DOF in the visual representation.
kwargs – arguments for the function add_bond, add_angle or add_dihedral, according to the case.
- Return type:
(list) list of DOFs of the same kind.
Example
dof=(1, 2) means a bond between atoms 1 and 2 dof=(1, 2, 3) means an angle between atoms 1, 2 and 3 dof=(1, 2, 3, 4) means a dihedral angle between atoms 1, 2, 3 and 4
- align_axis(vector)[source]
Apply the necessary rotations to set a vector aligned with positive x axis.
- Parameters:
vector (np.array) – vector to to be aligned.
- Returns:
(np.array) 3x3 transformation matrix to align the vector with the x
axis.
- align_plane(vector)[source]
Rotation around x axis to set a vector in the xy plane
- Parameters:
vector (np.array) – vector to be aligned.
- Returns:
(np.array) 3x3 transformation matrix to align the vector with the x
axis.
- apply_trans(atoms, trans, indexes=None)[source]
Apply a transformation to all vector positions of the atoms object
- Parameters:
atoms (ase.Atoms) – Atoms object to be transformed.
trans – 3x3 matrix containing the transformation.
indexes (Default=None (namely, all atoms)) – indexes of atoms to apply the transformation.
- Return type:
(np.array) array of new positions.
- download_image(*args, **kwargs)[source]
Download image.
- Parameters:
args – args for the function nglview.view.download_image.
kwargs – kwargs for the function nglview.view.download_image.
- Return type:
(bool) True.
- intermedia_vectors(a, b, n)[source]
Define the intermedia arc dots between two vectors
- Parameters:
a (array) – Vector of side a of the angle.
b (array) – Vector of side b of the angle.
n (int) – number of intermedia dots.
- Return type:
(list) Return the intermedia vectors between two side vectors.
- picked()[source]
Call the function picked of nglview that checks the last clicked object and shows the information related to it.
- Return type:
output of function nglview.view.picked
- remove_all_angles()[source]
Remove all angles.
- Return type:
(list) Return all the angles in the display.
- remove_all_dihedrals()[source]
Remove all dihedral angles.
- Return type:
(list) all the dihedral angles
- remove_angle(atom1index, atom2index, atom3index)[source]
Remove an angle if it exists
- Parameters:
atom1index (int) – Indexes of the first atom that defines the angle.
atom2index (int) – Indexes of the second atom that defines the angle.
atom3index (int) – Indexes of the third atom that defines the angle.
- Return type:
(list) Return all the angles in the display.
- remove_axis()[source]
remove xyz axis
- Return type:
(dict) axis as dict with cylinder shapes of nglview.
- remove_bond(atom1index, atom2index)[source]
Remove a bond between two atoms: atoms1 and atoms2.
- Parameters:
atom1index (int) – Indexes of the atoms that are connected. This bond will be removed.
atom2index (int) – Indexes of the atoms that are connected. This bond will be removed.
- Return type:
(list) Return the bonds in the system.
- remove_bonds(atoms1indexes=None, atoms2indexes=None)[source]
Remove several bonds in the plot between two list of atoms: atoms1 and atoms2.
- Parameters:
atoms1indexes (list[int]. Default=None) – Indexes of the atoms that are connected.
atoms2indexes (list[int]. Default=None) – Indexes of the atoms that are connected.
- Returns:
(list) Return the bonds in the system.
Note (if atoms2 is None, all bonds with atoms1 will me removed.)
If atoms1 and atoms2 are None, all bonds in the structure are
removed.
- remove_dihedral(atom1index, atom2index, atom3index, atom4index)[source]
Remove the dihedral angle between 4 atoms:
- Parameters:
atom1index (int) – Indexes of the first atom that defines the angle.
atom2index (int) – Indexes of the second atom that defines the angle.
atom3index (int) – Indexes of the third atom that defines the angle.
atom4index (int) – Indexes of the fourth atom that defines the angle.
- Return type:
(list) Return the dihedral angles.
- rot_x(angle)[source]
Returns the rotation matrix around x axis.
- Parameters:
angle (float) – angle to rotate in radians.
- Return type:
(np.array) 3x3 rotation matrix.
- rot_y(angle)[source]
Returns the rotation matrix around y axis.
- Parameters:
angle (float) – angle to rotate in radians.
- Return type:
(np.array) 3x3 rotation matrix.
- rot_z(angle)[source]
Returns the rotation matrix around z axis.
- Parameters:
angle (float) – angle to rotate in radians.
- Return type:
(np.array) 3x3 rotation matrix.
- xy_alignment(atoms, index1, index2, index3)[source]
Transforme the positions of the atoms such that the atoms of indexes 1 and 2 are aligned in the x axis
- Parameters:
atoms (ase.Atoms) – Atoms to be transformed.
index1 (int) – first atom to go in the x axis.
index2 (int) – second atom to go to the x axis.
index3 (int) – atom to go in the xy plane.
- Return type:
(np.array) numpy array with new positions.
- class sith.visualize.vmol.EnergiesVMol(sith_info: SITH, dofs: list = None, idef: int = 0, alignment: list | tuple | ndarray = None, show_axis: bool = False, background: list | color = vector(1, 1, 1), respect_to_total_energy: bool = False, **kwargs)[source]
Bases:
VMoleculeSet of graphic tools to visualize the distribution of energies in the different degrees of freedom (lengths, angles, dihedrals). Wrap to VMol.
- Parameters:
sith_info (SITH object.) – SITH object with the information of the system.
dofs (list. Default=None) – list of degrees of freedom defined according with 1-based indexing. It could also be ‘all’, ‘bonds’, ‘angles’ or ‘dihedrals’ to display all the corresponding DOFs.
idef (int. Default=0) – index of the stretching to be displayed.
alignment (list, tuple or np.ndarray. Default=None.) – indexes for the alignment of the molecule. See VMolecule.xy_alignment for more details.
show_axis (bool. Default=False.) – True if you want to show the axis in the scene.
background (list or vp.color. Default=vp.color.white.) – color of the background of the scene.
respect_to_total_energy (Default=False) – if true, the maximum of energies will be calculated with respect to the total energy of all the DOFs, not only the selected ones.
kwargs – other arguments for VMolecule.
- change_def(def_dict: dict, **kwargs) tuple[source]
This functions change the values stored in a dictionary and removes each one of the arguments from the kwargs.
- Parameters:
def_dict (dict) – dictionary with the default values.
kwargs (all the arguments you want to change.)
- Returns:
(dict, dict) modified dictionary withe the default values and set of
kwargs without the used keys.
- create_figure(dofs, respect_to_total_energy: bool = False, **kwargs)[source]
Creates the Color bar to be displayed at a side.
- Parameters:
dofs – DOFs to be displayed in the distribution.
respect_to_total_energy (bool. Default=False) – if true, the maximum of energies will be calculated with respect to the total energy of all the DOFs, not only the selected ones.
change_def (kwargs for)
- Return type:
(list, kwargs) normalized energies, not used kwargs.
- energies_all_dof(**kwargs) tuple[source]
Add all DOF with a color scale that represents the distribution of energy according to the JEDI method.
- Parameters:
EnergiesVMol.energies_some_dof (kwargs for)
- Return type:
(tuple) DOFs and their computed energies.
- energies_angles(**kwargs) tuple[source]
Add the angles with a color scale that represents the distribution of energy according to the JEDI method.
- Parameters:
EnergiesVMol.energies_some_dof (kwargs for)
- Return type:
(tuple) DOFs and their computed energies.
- energies_bonds(**kwargs) tuple[source]
Add the bonds with a color scale that represents the distribution of energy according to the JEDI method.
- Parameters:
EnergiesVMol.energies_some_dof (**kwargs for)
- Return type:
(tuple) DOFs and their computed energies.
- energies_dihedrals(**kwargs) tuple[source]
Add the dihedral angles with a color scale that represents the distribution of energy according to the JEDI method.
- Parameters:
EnergiesVMol.energies_some_dof (kwargs for)
- Return type:
(tuple) DOFs and their computed energies.
- energies_some_dof(dofs, **kwargs) tuple[source]
Add the dofs with a color scale that represents the distribution of energy according to the SITH method.
- Parameters:
dofs (list of tuples.) – list of degrees of freedom defined according with 1-based indexing.
normalize – normalization of colors acording to the range of energies and the colormap.
VMolecule.add_dof (kwargs of)
- Return type:
(list) VPython objects of the visual representation of DOFs.
- show_bonds(**kwargs) None[source]
Show the bonds in the molecule.
- Parameters:
add_dof (kwargs for)
- Return type:
(None)
Notes
The color is not related with the JEDI method. It could be changed with the kwarg color=rgb list.
- show_bonds_of_DOF(dof: list, unique: bool = False, color: list = None) dict[source]
Show bonds of a specific dof.
- Parameters:
dof (int.) – index in sith object that corresponds to the dof you want to show.
unique (Bool. default False.. Default=False) – True if you want to remove all the other bonds and only keeping these ones.
color (list[3(int)]. default R G B for angles, distances, dihedrals.) – color that you want to use in this dof.
- Returns:
(dict) all the DOFs in the system. keys -> dof names,
values -> vpython.objects
- show_dof(dofs: list, **kwargs) dict[source]
Show specific degrees of freedom.
- Parameters:
dofs (list of tuples.) – list of degrees of freedom defined according with 1-based indexing.
add_dof. (kwargs for)
- Returns:
(dict) all the DOFs in the system. keys -> dof names,
values -> vpython.objects
Notes
The color is not related with the JEDI method. It could be changed with the kwarg color=rgb list.