PyMovis is a Python package for visualizing molecular orbitals from quantum chemistry calculations. It reads Gaussian formatted checkpoint files, cube files, and PySCF checkpoint files, then renders 3D orbital isosurfaces with PyVista.
- Visualize molecular orbitals from
fchk,cube, andchkfiles - Select orbitals by index or by labels such as
HOMO,LUMO,HOMO-1,LUMO+2 - Render atoms, bonds, and orbital isosurfaces in 3D
- Use automatic camera placement with axis-based views
- Specify camera center and camera axes from atom indices
- Save high-quality images with transparent backgrounds
You can install PyMovis via pip install
pip install pymovisor from souce code.
git clone https://github.com/YusukeSugenami/pymovis.git
cd pymovis
pip install -e .The package installs a pymovis command.
pymovis test.fchk HOMOVisualize multiple orbitals:
pymovis test.fchk HOMO LUMOSave to specific output files:
pymovis test.fchk HOMO LUMO -o homo.png lumo.pngfrom pymovis import savemo
savemo("test.fchk", ["HOMO", "LUMO"])PyMoVis supports three levels of camera control.
Use camera_pos, camera_focal, and camera_up directly:
pymovis test.fchk HOMO \
-cp 10 10 10 \
-cf 0 0 0 \
-cu 0 1 0Use --camera_axis to place the camera so the molecule fits in the frame.
The current renderer defaults are used for this calculation:
- window size:
1024 x 768 - aspect ratio:
4:3 - vertical field of view:
30 deg
pymovis test.fchk HOMO --camera_axis XThis option looks at the molecule from the negative side of the selected axis and uses the corresponding screen orientation:
Xview: right is+Y, up is+ZYview: right is+X, up is+ZZview: right is+X, up is+Y
You can invert the axis direction with prefix '-' (e.g. -X)
You can define the camera center and axes from atom indices. Indices are 0-based.
Use --camera_focal_atoms.
- One atom index: the camera center is that atom position
- Two or more atom indices: the camera center is the centroid of those atoms
Example:
pymovis test.fchk HOMO --camera_focal_atoms 0
pymovis test.fchk HOMO --camera_focal_atoms 0 1 2Use --camera_axis_atoms for the camera view axis and --camera_up_atoms for the screen up direction.
- Two atom indices: the axis is the line through those atoms
- Three or more atom indices: the axis is the normal vector of the best-fit plane through those atoms
Example:
pymovis test.fchk HOMO \
--camera_focal_atoms 0 1 2 \
--camera_axis_atoms 0 1 \
--camera_up_atoms 0 1 3When using three or more atoms to define an axis (via best-fit plane normal), the sign of the resulting axis is ambiguous. You can fix this using --camera_axis_reference and --camera_up_reference.
Each reference option accepts:
- Two atom indices:
[idx1 idx2]→ the reference vector iscoords[idx2] - coords[idx1] - Three floats:
[X Y Z]→ the reference vector is given directly
The axis is flipped if its dot product with the reference vector is negative.
Example using atom indices:
pymovis test.fchk HOMO \
--camera_axis_atoms 0 1 2 \
--camera_up_atoms 3 4 5 \
--camera_axis_reference 0 1 \
--camera_up_reference 2 5Example using direct coordinates:
pymovis test.fchk HOMO \
--camera_axis_atoms 0 1 2 \
--camera_up_atoms 3 4 5 \
--camera_axis_reference 0 0 1 \
--camera_up_reference 0 1 0The current behavior is:
- If
--camera_axis_atomsand--camera_up_atomsare provided, those atom-based axes are used - Otherwise, if
--camera_axisis provided, the axis-based automatic camera is used - If
--camera_focalis provided, it becomes the camera center used by the automatic camera calculation - If
--camera_upis provided, it overrides the final up vector - If none of the automatic options are provided, manual
camera_pos,camera_focal, andcamera_upare used as-is
Usage: pymovis input_file [mo ...] [options]
Positional arguments:
input_file Gaussian fchk or cube file to visualize
mo MO indices to visualize
Use integer indices starting from 0 or labels such as HOMO/LUMO
Options:
-o, --out Output file names
-i, --iso Isosurface value
-t, --transparent Transparent background flag
-cp, --camera_pos Manual camera position
-cf, --camera_focal Manual camera focal point
-cu, --camera_up Manual camera up vector
-ca, --camera_axis Automatic camera axis: X / Y / Z. Use '-' prefix (e.g. -X) to invert the axis direction.
--camera_focal_atoms Atom indices used to define the camera focal point
--camera_axis_atoms Atom indices used to define the camera view axis
--camera_up_atoms Atom indices used to define the camera up axis
--camera_axis_reference Reference vector for camera view axis sign (2 atom indices or 3 coordinates)
--camera_up_reference Reference vector for camera up axis sign (2 atom indices or 3 coordinates)
-womo, --without_mo Only render molecule structure without MO isosurface
| Format | Extension | Description |
|---|---|---|
| Gaussian Formatted Checkpoint | .fchk |
Gaussian MO and geometry data |
| Cube File | .cube |
Cube grid data |
| PySCF checkpoint | .chk |
PySCF SCF checkpoint |
savemo(
inp_file,
mo_index,
out_name=None,
iso=0.03,
camera_pos=None,
camera_focal=None,
camera_up=None,
camera_axis=None,
camera_focal_atoms=None,
camera_axis_atoms=None,
camera_up_atoms=None,
camera_axis_reference=None,
camera_up_reference=None,
transparent_background=True,
without_mo=False,
)inp_file: input file pathmo_index: list of MO indices or labelsout_name: output file namesiso: isosurface valuecamera_axis: automatic axis-based view (X,Y,Z)camera_focal_atoms: atom indices for the camera focal pointcamera_axis_atoms: atom indices for the view axiscamera_up_atoms: atom indices for the up axiscamera_axis_reference: reference vector for camera axis sign (2 atom indices or 3D coordinates)camera_up_reference: reference vector for camera up axis sign (2 atom indices or 3D coordinates)transparent_background: save transparent background picture if Truewithout_mo: save only molecular structure if True
from pymovis import load_inp
mol = load_inp("test.fchk")Returns a MoleculeData object with parsed geometry, basis, and MO data.
If you want to use the camera logic directly, the package exposes helper functions such as:
from pymovis import (
infer_camera_from_coords,
infer_axis_camera_fit_from_coords,
infer_atom_axis_camera_fit_from_coords,
)Default rendering and parser settings are defined in pymovis/settings.py.
Important values include:
PADDINGGRID_SETTINGGRID_SHAPEIMAGE_QUALITYBACKGROUND_COLORPARSER_ARGS
pymovis water.fchk HOMOpymovis water.fchk HOMO LUMO --camera_axis Zpymovis water.fchk HOMO \
--camera_focal_atoms 0 1 2 \
--camera_axis_atoms 0 1 \
--camera_up_atoms 0 1 3pymovis water.fchk HOMO --transparent True