ai4materials.utils.utils_vol_data module

ai4materials.utils.utils_vol_data.get_shells_from_indices(xyz_r, vol_data)[source]

Obtain concentric shells from volumetric data.

The starting point are an array containing the volumetric data and a list of indices which assign points of the volume to the corresponding concentric shell. Using these indices, we perform two operations:

  1. extract the concentric shells in the volumetric space
  2. transform the concentric shells to spherical coordinates, i.e. project each sphere to a (theta, phi) plane

Point 1) gives volumetric 3d data containing a given shell. Point 2) gives 2d data in the (theta, phi) plane for a given shell; this can be interpreted as a heatmap.

Parameters:

xyz_r: list of list of tuples
The length of the list corresponds to the number of concentric shells considered. Each element in the list - representing a concentric shell - contains a list of 3 dimensional tuples, with the indices of the volume elements which belong to the given concentric shell. This is the list returned by ai4materials.utils.utils_vol_data.get_slice_volume_indices.
vol_data: numpy.ndarray
Volumetric data as numpy.ndarray.

Return: vox_by_slices, theta_phi_by_slices

vox_by_slices: np.ndarray, shape [n_slices, n_px, n_py, n_pz]
4-dimensional array containing each concentric shell obtained from ai4materials.descriptors.diffraction3d.Diffraction3D. n_px, n_py, n_pz are given by the interpolation and the region of the space considered. In our case, n_slices=52, n_px=n_py=n_pz=176.
theta_phi_by_slices: list of tuples
Each element in the list correspond to a concentric shell. In each concentric shell, there is a list of tuples (theta, phi, intensity) of the non-zero points in the volume considered, as return by ai4materials.utils.utils_vol_data.shells_to_sph. The length of the tuple list of each concentric shell is different because a different number of points is non-zero for each shell.

Code author: Angelo Ziletti <angelo.ziletti@gmail.com>

ai4materials.utils.utils_vol_data.get_slice_volume_indices(vol_data, min_r, max_r, dr=1.0, phi_bins=100, theta_bins=50)[source]

Given 3d volume return the indices of points belonging to the specified concentric shells.

The volume is should be centered according to its center of mass to have centered concentric shells. In our case we do not have to do that because the diffraction intensity obtained with the Fourier Transform is centered by definition. For use reference, we nevertheless calculate the center of mass within the function.

Parameters:

vol_data:
Numpy 3D array containing the volumetric data to be sliced. In our case, this is the three-dimensional diffraction intensity.
theta_bins: int, optional (default=50)
Bins to be used for the theta angle of the spherical coordinates.
phi_bins: int, optional (default=100)
Bins to be used for the phi angle of the spherical coordinates.
Returns: list
List of length = (max_r - min_r)/dr; the length corresponds to the number of concentric shells considered. Each element in the list - representing a concentric shell - contains a list of 3 dimensional tuples, with the indices of the volume elements which belong to the given concentric shell. For example, let us assume the output of the function is stored in variable xyz_r. xyz[0] gives a list of tuples corresponding to the points in the first concentric shell. If xyz[0][0] = (82, 97, 119), this means that the element of the volumetric shape with index (82, 97, 119) belong to the first shell.

Code author: Angelo Ziletti <angelo.ziletti@gmail.com>

ai4materials.utils.utils_vol_data.interp_theta_phi_surfaces(theta_phi_by_slices_coarse, theta_bins=256, phi_bins=512)[source]

Interpolate the spherical shells in spherical coordinate to a finer grid.

For more information on the interpolation, please refer to: http://scipy-cookbook.readthedocs.io/items/Matplotlib_Gridding_irregularly_spaced_data.html

theta_phi_by_slices_coarse: list of tuples
Each element in the list correspond to a concentric shell. In each concentric shell, there is a list of tuples (theta, phi, intensity) of the non-zero points in the volume considered, as return by ai4materials.utils.utils_vol_data.shells_to_sph. The length of the tuple list of each concentric shell is different because a different number of points is non-zero for each shell.
theta_bins: int, optional (default=256)
Bins to be used for the interpolation of the theta angle of the spherical coordinates.
phi_bins: int, optional (default=512)
Bins to be used for the interpolation of the phi angle of the spherical coordinates.
Return: np.ndarray, shape [n_slices, theta_bins_fine, phi_bins_fine]
Three-dimensional array containing each concentric shell in spherical coordinate. n_slices is given by the region of the space considered.

Code author: Angelo Ziletti <angelo.ziletti@gmail.com>