DensitySpace.VoxelSpace#
DensitySpace.VoxelSpace.py
- get_meshgrid(N)#
Create a meshgrid for the electron density space.
- Parameters:
N (int) – The size of the grid along each axis.
- Returns:
A tuple containing the meshgrid arrays (x, y, z).
- Return type:
tuple
- draw_voxles_as_dots_impl(ax, image, cmap=<matplotlib.colors.ListedColormap object>, min_value=0, colorbar=False, limits=None, alpha=1, s=30)#
Draw voxels as dots in a 3D plot.
- Parameters:
ax (matplotlib.axes.Axes) – The axes to plot on.
image (np.ndarray) – The 3D density array.
min_value (float) – The minimum density value to consider for plotting.
colorbar (bool) – Whether to display a colorbar.
limits (tuple or None) – The limits for the axes in the form (xlim, ylim, zlim). If None, the limits will be set to the size of the image.
alpha (float) – The alpha value for the dots.
s (float) – The size of the dots.
- Return type:
None
- add_center_plane(ax, N, k=None, alpha=0.2, color='gray')#
Add a plane at z=k to the 3D axes.
- Parameters:
ax (matplotlib.axes.Axes) – The axes to plot on.
N (int) – The size of the grid along each axis.
k (int or None) – The z value for the plane. If None, it will be set to N//2
alpha (float) – The alpha value for the plane.
- compute_rg_impl(rho, min_value=0)#
Compute the radius of gyration for a 3D density array. (This code was generated by Copilot)
- Parameters:
rho (np.ndarray) – 3D density array.
min_value (float) – Minimum density value to include in calculation.
- Returns:
Radius of gyration.
- Return type:
float
- class VoxelSpace(N, shape=None, density=None)#
Bases:
object
VoxelSpace class to handle voxel-based density spaces. It can be initialized with a shape or a density array.
- rho#
3D density array.
- Type:
np.ndarray
- plot_as_dots(ax=None, cmap=<matplotlib.colors.ListedColormap object>, min_value=0, colorbar=False, alpha=1, s=30)#
Plot the voxel space.
- Parameters:
ax (matplotlib.axes.Axes) – The axes to plot on.
min_value (float) – The minimum density value to consider for plotting.
- plot_with_density(axes=None, cmap=<matplotlib.colors.ListedColormap object>, min_value=0.0001, colorbar=True, alpha=0.3, s=1, k=None)#
Plot the voxel space.
- Parameters:
axes (matplotlib.axes.Axes) – The axes to plot on.
min_value (float) – The minimum density value to consider for plotting.
colorbar (bool) – Whether to display a colorbar.
alpha (float) – The alpha value for the plots.
s (float) – The size of the dots.
k (int or None) – The z value for the cross-sectional plane. If None, it will be set to N//2
- Return type:
None
- compute_rg(min_value=0)#
Compute the radius of gyration of the voxel space.
- Parameters:
min_value (float) – Minimum density value to include in calculation.
- Returns:
The radius of gyration.
- Return type:
float