PyCosmoMMF 0.0.6__tar.gz → 0.0.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/PKG-INFO +1 -1
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/PyCosmoMMF/__init__.py +8 -1
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/PyCosmoMMF/filter.py +8 -8
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/PyCosmoMMF/hessian.py +1 -1
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/PyCosmoMMF/signatures.py +20 -13
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/PyCosmoMMF.egg-info/PKG-INFO +1 -1
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/setup.py +1 -1
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/LICENSE +0 -0
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/MANIFEST.in +0 -0
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/PyCosmoMMF/tagging.py +0 -0
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/PyCosmoMMF/test_density_cube.npy +0 -0
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/PyCosmoMMF/utils.py +0 -0
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/PyCosmoMMF.egg-info/SOURCES.txt +0 -0
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/PyCosmoMMF.egg-info/dependency_links.txt +0 -0
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/PyCosmoMMF.egg-info/top_level.txt +0 -0
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/README.md +0 -0
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/pyproject.toml +0 -0
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/requirements.txt +0 -0
- {PyCosmoMMF-0.0.6 → PyCosmoMMF-0.0.8}/setup.cfg +0 -0
|
@@ -10,7 +10,14 @@ import pkg_resources
|
|
|
10
10
|
|
|
11
11
|
test_field = np.load(pkg_resources.resource_filename(__name__, 'test_density_cube.npy'))
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
def version():
|
|
14
|
+
"""
|
|
15
|
+
Print the version of the package.
|
|
16
|
+
"""
|
|
17
|
+
__version__ = '0.0.8'
|
|
18
|
+
|
|
19
|
+
print("PyCosmoMMF version: ", __version__)
|
|
20
|
+
|
|
14
21
|
|
|
15
22
|
|
|
16
23
|
|
|
@@ -26,9 +26,9 @@ def wavevectors3D(dims, box_size=(2*np.pi, 2*np.pi, 2*np.pi)):
|
|
|
26
26
|
The wavevectors in each dimension.
|
|
27
27
|
"""
|
|
28
28
|
sample_rate = 2*np.pi * (np.array(dims) / box_size)
|
|
29
|
-
kx = np.fft.fftfreq(dims[0], 1/sample_rate[0]) * (2*np.pi / dims[0])
|
|
30
|
-
ky = np.fft.fftfreq(dims[1], 1/sample_rate[1]) * (2*np.pi / dims[1])
|
|
31
|
-
kz = np.fft.fftfreq(dims[2], 1/sample_rate[2]) * (2*np.pi / dims[2])
|
|
29
|
+
kx = (np.fft.fftfreq(dims[0], 1/sample_rate[0]) * (2*np.pi / dims[0])).astype(np.float32)
|
|
30
|
+
ky = (np.fft.fftfreq(dims[1], 1/sample_rate[1]) * (2*np.pi / dims[1])).astype(np.float32)
|
|
31
|
+
kz = (np.fft.fftfreq(dims[2], 1/sample_rate[2]) * (2*np.pi / dims[2])).astype(np.float32)
|
|
32
32
|
return kx, ky, kz
|
|
33
33
|
|
|
34
34
|
@jit_compiler
|
|
@@ -50,7 +50,7 @@ def kspace_gaussian_filter(R_S, kv):
|
|
|
50
50
|
"""
|
|
51
51
|
kx, ky, kz = kv
|
|
52
52
|
nx, ny, nz = len(kx), len(ky), len(kz)
|
|
53
|
-
filter_k = np.zeros((nx, ny, nz))
|
|
53
|
+
filter_k = np.zeros((nx, ny, nz), dtype=np.float32)
|
|
54
54
|
for ix in nb.prange(nx):
|
|
55
55
|
for iy in range(ny):
|
|
56
56
|
for iz in range(nz):
|
|
@@ -78,7 +78,7 @@ def kspace_top_hat_filter(R_S, kv):
|
|
|
78
78
|
|
|
79
79
|
kx, ky, kz = kv
|
|
80
80
|
nx, ny, nz = len(kx), len(ky), len(kz)
|
|
81
|
-
filter_k = np.zeros((nx, ny, nz))
|
|
81
|
+
filter_k = np.zeros((nx, ny, nz), dtype=np.float32)
|
|
82
82
|
|
|
83
83
|
for ix in nb.prange(nx):
|
|
84
84
|
for iy in range(ny):
|
|
@@ -112,7 +112,7 @@ def smooth_top_hat(f, R_S, kv):
|
|
|
112
112
|
GF = kspace_top_hat_filter(R_S, kv)
|
|
113
113
|
f_Rn = np.real(np.fft.ifftn(GF * np.fft.fftn(f)))
|
|
114
114
|
f_Rn = f_Rn * (np.sum(f) / np.sum(f_Rn))
|
|
115
|
-
return f_Rn
|
|
115
|
+
return f_Rn.astype(np.float32)
|
|
116
116
|
|
|
117
117
|
def smooth_gauss(f, R_S, kv):
|
|
118
118
|
"""
|
|
@@ -135,7 +135,7 @@ def smooth_gauss(f, R_S, kv):
|
|
|
135
135
|
GF = kspace_gaussian_filter(R_S, kv)
|
|
136
136
|
f_Rn = np.real(np.fft.ifftn(GF * np.fft.fftn(f)))
|
|
137
137
|
f_Rn = f_Rn * (np.sum(f) / np.sum(f_Rn))
|
|
138
|
-
return f_Rn
|
|
138
|
+
return f_Rn.astype(np.float32)
|
|
139
139
|
|
|
140
140
|
|
|
141
141
|
def smooth_loggauss(f, R_S, kv):
|
|
@@ -178,5 +178,5 @@ def smooth_loggauss(f, R_S, kv):
|
|
|
178
178
|
norm = np.sum(f) / np.sum(f_result)
|
|
179
179
|
f_result *= norm
|
|
180
180
|
|
|
181
|
-
return f_result
|
|
181
|
+
return f_result.astype(np.float32)
|
|
182
182
|
|
|
@@ -30,7 +30,7 @@ def fast_hessian_from_smoothed(f_Rn, R_S, kv):
|
|
|
30
30
|
|
|
31
31
|
f_Rn_hat = np.fft.fftn(f_Rn)
|
|
32
32
|
dims = f_Rn_hat.shape
|
|
33
|
-
hessian = np.zeros((dims[0], dims[1], dims[2], 6), dtype=np.
|
|
33
|
+
hessian = np.zeros((dims[0], dims[1], dims[2], 6), dtype=np.complex64)
|
|
34
34
|
kx, ky, kz = kv[0], kv[1], kv[2]
|
|
35
35
|
|
|
36
36
|
@jit_compiler
|
|
@@ -29,7 +29,7 @@ def signatures_from_hessian(hessian):
|
|
|
29
29
|
"""
|
|
30
30
|
|
|
31
31
|
hsize = hessian.shape[:3]
|
|
32
|
-
sigs = np.zeros((hsize[0], hsize[1], hsize[2], 3))
|
|
32
|
+
sigs = np.zeros((hsize[0], hsize[1], hsize[2], 3), dtype=np.float32)
|
|
33
33
|
|
|
34
34
|
#helper functions
|
|
35
35
|
def θ(x):
|
|
@@ -59,20 +59,25 @@ def signatures_from_hessian(hessian):
|
|
|
59
59
|
])
|
|
60
60
|
|
|
61
61
|
e1, e2, e3 = np.sort(np.real(np.linalg.eigvals(hes_slice)))
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
|
|
63
|
+
if e1 == 0:
|
|
64
|
+
sigs[i,j,k,0] = 0
|
|
65
|
+
sigs[i,j,k,1] = 0
|
|
66
|
+
sigs[i,j,k,2] = 0
|
|
67
|
+
else:
|
|
68
|
+
sigs[i,j,k,0] = (np.abs(e3 / e1) *
|
|
69
|
+
np.abs(e3)) * (θ(-e1) * θ(-e2) * θ(-e3))
|
|
70
|
+
|
|
71
|
+
sigs[i,j,k,1] = (np.abs(e2 / e1) *
|
|
72
|
+
xθ(1-np.abs(e3 / e1))) * (np.abs(e2) * θ(-e1) * θ(-e2) )
|
|
73
|
+
|
|
74
|
+
sigs[i,j,k,2] = (xθ(1-np.abs(e2 / e1)) *
|
|
75
|
+
xθ(1-np.abs(e3 / e1))) * (np.abs(e1) * θ(-e1))
|
|
71
76
|
|
|
72
77
|
return sigs
|
|
73
78
|
|
|
74
79
|
|
|
75
|
-
def maximum_signature(Rs, field, alg='NEXUSPLUS'):
|
|
80
|
+
def maximum_signature(Rs, field, alg='NEXUSPLUS', eps=1e-8):
|
|
76
81
|
"""
|
|
77
82
|
Compute the maximum signatures across all scales Rs.
|
|
78
83
|
|
|
@@ -85,6 +90,8 @@ def maximum_signature(Rs, field, alg='NEXUSPLUS'):
|
|
|
85
90
|
alg : string, optional
|
|
86
91
|
The algorithm to use. Can be either 'NEXUS' or 'NEXUSPLUS'.
|
|
87
92
|
Default is 'NEXUSPLUS'.
|
|
93
|
+
eps : float, optional
|
|
94
|
+
A small number to avoid division by zero errors and whatnot. Default is 1e-8.
|
|
88
95
|
|
|
89
96
|
Returns
|
|
90
97
|
-------
|
|
@@ -97,13 +104,13 @@ def maximum_signature(Rs, field, alg='NEXUSPLUS'):
|
|
|
97
104
|
nx, ny, nz = field.shape
|
|
98
105
|
|
|
99
106
|
# Make sure the field has no 0 values
|
|
100
|
-
field = field +
|
|
107
|
+
field = field + eps
|
|
101
108
|
|
|
102
109
|
# Calculate wave vectors for our field
|
|
103
110
|
wave_vecs = wavevectors3D((nx, ny, nz))
|
|
104
111
|
|
|
105
112
|
# Calculate signatures at each scale Rn, determine max
|
|
106
|
-
sigmax = np.ones((nx, ny, nz, 3)) *
|
|
113
|
+
sigmax = np.ones((nx, ny, nz, 3), dtype=np.float32) * eps
|
|
107
114
|
|
|
108
115
|
@jit_compiler
|
|
109
116
|
def perform_loop(sigmax, sigs_Rn, nx, ny, nz):
|
|
@@ -12,7 +12,7 @@ here = pathlib.Path(__file__).parent.resolve()
|
|
|
12
12
|
|
|
13
13
|
setup(
|
|
14
14
|
name='PyCosmoMMF', # Required
|
|
15
|
-
version='0.0.
|
|
15
|
+
version='0.0.8', # Required
|
|
16
16
|
description='A package for detecting structures in the Cosmic Web.', # Optional
|
|
17
17
|
long_description=(here / 'README.md').read_text(encoding='utf-8'), # Optional
|
|
18
18
|
long_description_content_type='text/markdown', # Optional (see note above)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|