Coverage for local_installation_linux/mumott/methods/utilities/grids_on_the_sphere.py: 58%
22 statements
« prev ^ index » next coverage.py v7.3.2, created at 2025-05-05 21:21 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2025-05-05 21:21 +0000
1import numpy as np
2from numpy.typing import NDArray
5def TOMCAT_7(half_sphere: bool = True) -> NDArray:
6 r""" The seven sensitivity directions used in publications by the TOMCAT group.
8 Parameters
9 ----------
10 half_sphere
11 Whether to use points only covering the half sphere or the full sphere.
13 Returns
14 ---------
15 directions
16 Array with shape ``(N, 3)`` containing the coordinated of the ``N`` unit vectors.
17 """
19 # Hard coded {100} and {111} cubic directions in the +z hemisphere
20 directions = [[1.0, 0.0, 0.0],
21 [0.0, 1.0, 0.0],
22 [0.0, 0.0, 1.0],
23 [1.0, 1.0, 1.0],
24 [1.0, -1.0, 1.0],
25 [-1.0, 1.0, 1.0],
26 [-1.0, -1.0, 1.0]]
28 directions = np.stack(directions)
30 if not half_sphere:
31 directions = np.concatenate((directions, -directions), axis=0)
33 # Normalize
34 norm = np.linalg.norm(directions, axis=1)
35 directions = directions/norm[:, np.newaxis]
37 return directions
40def football(half_sphere=True) -> NDArray:
41 r""" 16 sensitivity directions uniformly distributed on the half sphere.
43 Parameters
44 ----------
45 half_sphere
46 Whether to use points only covering the half sphere or the full sphere.
48 Returns
49 ---------
50 directions
51 Array with shape ``(N, 3)`` containing the coordinated of the ``N`` unit vectors.
52 """
54 # football face centers in the +z hemisphere
55 C0 = 3*(np.sqrt(5) - 1)/4
56 C1 = 9*(9 + np.sqrt(5))/76
57 C2 = 9*(7 + 5 * np.sqrt(5))/76
58 C3 = 3*(1 + np.sqrt(5))/4
60 directions = np.array([[0.0, C0, C3],
61 [0.0, -C0, C3],
62 [C3, 0.0, C0],
63 [-C3, 0.0, C0],
64 [C0, C3, 0.0],
65 [-C0, C3, 0.0],
66 [C1, 0.0, C2],
67 [-C1, 0.0, C2],
68 [C2, C1, 0.0],
69 [-C2, C1, 0.0],
70 [0.0, C2, C1],
71 [0.0, -C2, C1],
72 [1.5, 1.5, 1.5],
73 [1.5, -1.5, 1.5],
74 [-1.5, 1.5, 1.5],
75 [-1.5, -1.5, 1.5]])
77 directions = np.stack(directions)
79 if not half_sphere: 79 ↛ 80line 79 didn't jump to line 80, because the condition on line 79 was never true
80 directions = np.concatenate((directions, -directions), axis=0)
82 # Normalize
83 norm = np.linalg.norm(directions, axis=1)
84 directions = directions / norm[:, np.newaxis]
86 return directions