molgri.space.analysis
Analysis of uniformity of 3D and 4D sphere grids.
Always performed by selecting random vectors and evaluating how many grid points fall within the spherical cap area around this vector. Ideally, the ratio of points within the spherical cap and all points should be equal to the ratio of sphere cap area and full sphere area. For quaternions, double-coverage must be considered.
Functions
|
Count how many points fall within spherical cap with central angle alpha around the central vector. |
|
Prepare statistics data that is used for ViolinPlots, either based on 3D points or on quaternions. |
|
Repeat count_points_within_alpha for many random selections of the central vector. |
|
Same as random_axes_count_points, but because we are dealing with quaternions, random axes are defined differently and quaternion signs are randomised first. |
|
Calculate the angle between each pair of vectors in zip(central_vec, side_vector). |
|
The top-level method that writes full statistics and a summary to files. |
- molgri.space.analysis.vector_within_alpha(central_vec: ndarray[Any, dtype[ScalarType]], side_vec: ndarray[Any, dtype[ScalarType]], alpha: float) ndarray[Any, dtype[bool]]
Calculate the angle between each pair of vectors in zip(central_vec, side_vector). Return an array in which True is given where the angle is smaller than alpha and False where not.
- Args:
central_vec: a single vector of shape (d,) or an array of vectors of shape (n1, d) side_vec: a single vector of shape (d,) or an array of vectors of shape (n2, d) alpha: in radians, angle around central_vec where we check if side_vectors occur
- Returns:
- array of bools of shape (n1, n2) if both vectors are 2D
of shape (n2,) if central_vec is 1D and side_vec 2D of shape (n1,) if central_vec is 2D and side_vec 1D of shape (1,) if both vectors are 1D
- molgri.space.analysis.count_points_within_alpha(array_points: ndarray[Any, dtype[ScalarType]], central_vec: ndarray[Any, dtype[ScalarType]], alpha: float) int
Count how many points fall within spherical cap with central angle alpha around the central vector.
- Args:
array_points: each row is a point on a sphere that may or may not be within a spherical cap area central_vec: defines the center of spherical cap alpha: defines the width of spherical cap
- Returns:
the number of rows within array_points that are vectors with endings in the spherical cap area.
- molgri.space.analysis.random_axes_count_points(array_points: ndarray[Any, dtype[ScalarType]], alpha: float, num_random_points: int = 1000) ndarray[Any, dtype[ScalarType]]
Repeat count_points_within_alpha for many random selections of the central vector. Using this, we get a good estimate of uniformity across the entire sphere.
- Args:
array_points: each row is a point on a sphere alpha: defines the width of spherical cap num_random_points: how many random central vectors to test
- Returns:
Array of shape (num_random_points,) where for each random central vector the ratio array points within spherical cal/all array points is saved
- molgri.space.analysis.random_quaternions_count_points(array_points: ndarray, alpha: float, num_random_points: int = 1000)
Same as random_axes_count_points, but because we are dealing with quaternions, random axes are defined differently and quaternion signs are randomised first.
- molgri.space.analysis.prepare_statistics(point_array: ndarray[Any, dtype[ScalarType]], alphas: list, d: int = 3, num_rand_points: int = 1000) Tuple
Prepare statistics data that is used for ViolinPlots, either based on 3D points or on quaternions.
- Args:
point_array: an array of points for which coverage is tested, must be of the shape (N, d) alphas: a list of angles in radians at which convergence is tested d: number of dimensions (3 or 4) num_rand_points: number of random axes around which convergence is tested
- Returns:
(data_frame_summary, data_frame_full)
- molgri.space.analysis.write_statistics(stat_data: DataFrame, full_data: DataFrame, path_summary: str, path_full_data: str, num_random: int, name: str, dimensions: int, print_message: bool = False)
The top-level method that writes full statistics and a summary to files. Only deals with messages/files, all calculations are outsourced to other functions
- Args:
stat_data: summary data returned by prepare_statistics function full_data: full data returned by prepare_statistics function path_summary: where to save summary path_full_data: where to save full data num_random: number of random orientations when calculating statistics name: ID of the system dimensions: 3 or 4 dimensions (determine sphere and spherical area formulas) print_message: True if a summary message should be printed out