PyCosmoMMF 0.0.2__tar.gz → 0.0.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyCosmoMMF
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: A package for detecting structures in the Cosmic Web.
5
5
  Home-page: https://github.com/James11222/PyCosmoMMF/
6
6
  Author: James Sunseri
@@ -50,6 +50,62 @@ def kspace_gaussian_filter(R_S, kv):
50
50
  -(kx[ix]**2 + ky[iy]**2 + kz[iz]**2) * R_S**2 / 2)
51
51
  return filter_k
52
52
 
53
+ @nb.njit(parallel=True, fastmath=True)
54
+ def kspace_top_hat_filter(R_S, kv):
55
+ """
56
+ create a top-hat filter in k-space.
57
+
58
+ Parameters
59
+ ----------
60
+ R_S : float
61
+ The smoothing scale.
62
+ kv : tuple
63
+ The wavevectors in each dimension.
64
+
65
+ Returns
66
+ -------
67
+ filter_k : array
68
+ The filter in k-space.
69
+ """
70
+
71
+ kmax = (2 * np.pi) / R_S
72
+
73
+ kx, ky, kz = kv
74
+ nx, ny, nz = len(kx), len(ky), len(kz)
75
+ filter_k = np.zeros((nx, ny, nz))
76
+
77
+ for ix in range(nx):
78
+ for iy in range(ny):
79
+ for iz in range(nz):
80
+ if (np.sqrt(kx[ix]**2 + ky[iy]**2 + kz[iz]**2)) < kmax:
81
+ filter_k[ix, iy, iz] = 1
82
+
83
+ return filter_k
84
+
85
+
86
+ def smooth_top_hat(f, R_S, kv):
87
+ """
88
+ apply a top-hat filter to a field f.
89
+
90
+ Parameters
91
+ ----------
92
+ f : array
93
+ The field to be smoothed.
94
+ R_S : float
95
+ The smoothing scale.
96
+ kv : tuple
97
+ The wavevectors in each dimension.
98
+
99
+ Returns
100
+ -------
101
+ f_Rn : array
102
+ The smoothed field.
103
+ """
104
+ GF = kspace_top_hat_filter(R_S, kv)
105
+ f_Rn = np.real(np.fft.ifftn(GF * np.fft.fftn(f)))
106
+ f_Rn = f_Rn * (np.sum(f) / np.sum(f_Rn))
107
+ return f_Rn
108
+
53
109
  def smooth_gauss(f, R_S, kv):
54
110
  """
55
111
  apply a Gaussian filter to a field f.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyCosmoMMF
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: A package for detecting structures in the Cosmic Web.
5
5
  Home-page: https://github.com/James11222/PyCosmoMMF/
6
6
  Author: James Sunseri
@@ -12,7 +12,7 @@ here = pathlib.Path(__file__).parent.resolve()
12
12
 
13
13
  setup(
14
14
  name='PyCosmoMMF', # Required
15
- version='0.0.2', # Required
15
+ version='0.0.3', # 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