PyCosmoMMF 0.3.0__tar.gz → 0.4.0__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.
Files changed (68) hide show
  1. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/PKG-INFO +1 -1
  2. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/src/pycosmommf/_version.py +2 -2
  3. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/src/pycosmommf/tagging.py +36 -21
  4. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/.copier-answers.yml +0 -0
  5. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/.git_archival.txt +0 -0
  6. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/.gitattributes +0 -0
  7. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/.github/CONTRIBUTING.md +0 -0
  8. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/.github/dependabot.yml +0 -0
  9. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/.github/release.yml +0 -0
  10. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/.github/workflows/cd.yml +0 -0
  11. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/.github/workflows/ci.yml +0 -0
  12. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/.gitignore +0 -0
  13. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/.pre-commit-config.yaml +0 -0
  14. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/.readthedocs.yaml +0 -0
  15. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/LICENSE +0 -0
  16. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/README.md +0 -0
  17. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/CosmoMMF_Dark.png +0 -0
  18. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/CosmoMMF_light.png +0 -0
  19. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/basic.css +0 -0
  20. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/check-solid.svg +0 -0
  21. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/clipboard.min.js +0 -0
  22. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/copy-button.svg +0 -0
  23. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/copybutton.css +0 -0
  24. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/copybutton.js +0 -0
  25. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/copybutton_funcs.js +0 -0
  26. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/debug.css +0 -0
  27. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/doctools.js +0 -0
  28. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/documentation_options.js +0 -0
  29. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/file.png +0 -0
  30. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/language_data.js +0 -0
  31. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/minus.png +0 -0
  32. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/plus.png +0 -0
  33. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/pygments.css +0 -0
  34. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/scripts/furo-extensions.js +0 -0
  35. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/scripts/furo.js +0 -0
  36. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/scripts/furo.js.LICENSE.txt +0 -0
  37. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/scripts/furo.js.map +0 -0
  38. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/searchtools.js +0 -0
  39. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/skeleton.css +0 -0
  40. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/sphinx_highlight.js +0 -0
  41. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/styles/furo-extensions.css +0 -0
  42. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/styles/furo-extensions.css.map +0 -0
  43. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/styles/furo.css +0 -0
  44. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/_static/styles/furo.css.map +0 -0
  45. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/api/pycosmommf.rst +0 -0
  46. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/api_tab.md +0 -0
  47. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/basic_usage.md +0 -0
  48. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/conf.py +0 -0
  49. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/images/CosmoMMF_Dark.png +0 -0
  50. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/images/CosmoMMF_light.png +0 -0
  51. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/images/final_NEXUSPLUS_Signatures_hydro.png +0 -0
  52. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/images/final_NEXUSPLUS_Signatures_hydro_dark.png +0 -0
  53. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/images/final_tagging_figure.png +0 -0
  54. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/images/final_tagging_figure_dark.png +0 -0
  55. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/docs/index.md +0 -0
  56. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/noxfile.py +0 -0
  57. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/pyproject.toml +0 -0
  58. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/src/pycosmommf/__init__.py +0 -0
  59. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/src/pycosmommf/_version.pyi +0 -0
  60. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/src/pycosmommf/filter.py +0 -0
  61. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/src/pycosmommf/hessian.py +0 -0
  62. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/src/pycosmommf/py.typed +0 -0
  63. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/src/pycosmommf/signatures.py +0 -0
  64. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/src/pycosmommf/utils.py +0 -0
  65. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/tests/__init__.py +0 -0
  66. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/tests/test_integration.py +0 -0
  67. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/tests/test_package.py +0 -0
  68. {pycosmommf-0.3.0 → pycosmommf-0.4.0}/tests/test_unit.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pycosmommf
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: A package for identifying structures in the cosmic web.
5
5
  Project-URL: Homepage, https://github.com/James11222/pycosmommf
6
6
  Project-URL: Bug Tracker, https://github.com/James11222/pycosmommf/issues
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.3.0'
16
- __version_tuple__ = version_tuple = (0, 3, 0)
15
+ __version__ = version = '0.4.0'
16
+ __version_tuple__ = version_tuple = (0, 4, 0)
@@ -1,10 +1,11 @@
1
1
  from __future__ import annotations
2
2
 
3
- import functools
4
-
3
+ import numba as nb
5
4
  import numpy as np
6
5
  import skimage.measure
7
6
 
7
+ jit_compiler = nb.njit(parallel=True, fastmath=True)
8
+
8
9
 
9
10
  def make_the_clusbool(delta, max_sigs, Δ): # pragma: no cover
10
11
  """
@@ -16,43 +17,57 @@ def make_the_clusbool(delta, max_sigs, Δ): # pragma: no cover
16
17
  change in virialization fraction as a function of 𝒮_cluster.
17
18
 
18
19
  Arguments:
19
-
20
+ ----------------
20
21
  delta - [3D Float Array] - delta refers to the δ delta.
21
22
  max_sigs - [4D Float Array] - the maximum signatures array from CosmoMMF.maximum_signature()
22
23
  verbose - [Boolean] - a flag to allow the function to be more helpful and verbose.
23
24
  Δ - [Int] - The overdensity parameter threshold for determining virialization. This
24
25
  parameter comes from a paper by Gunn & Gott on spherical collapse. Commonly
25
26
  used values that are physically motivated can be 370, 200, or 500 (for R_200 or R_500).
27
+
28
+ Returns:
29
+ ----------------
30
+ clusbool - [3D Boolean Array] - a boolean filter that selects only the clusters in a given cosmological δ field.
31
+ S_th - [Float] - the threshold value for 𝒮_cluster.
32
+ signature_thresholds - [1D Float Array] - an array of threshold values for 𝒮_cluster.
33
+ virialized_fractions - [1D Float Array] - an array of virialized fractions as a function of 𝒮_cluster.
26
34
  """
27
35
 
28
36
  signature_thresholds = np.geomspace(0.1, 30, 10) # hard coded for now
29
37
  virialized_fractions = np.zeros_like(signature_thresholds)
30
38
 
31
- def check_virialized(j, delta, clumps, Δ):
32
- δ_ave = np.mean(delta[clumps == j])
33
- return int(δ_ave > Δ)
39
+ @jit_compiler
40
+ def calc_virialized_fraction(clumps):
41
+ nx, ny, nz = clumps.shape
42
+
43
+ total_clumps_detected = np.max(clumps)
44
+ summed_overdensity_per_clump = np.zeros(total_clumps_detected)
45
+ num_cells_per_clump = np.zeros(total_clumps_detected)
46
+
47
+ for i in nb.prange(nx):
48
+ for j in range(ny):
49
+ for k in range(nz):
50
+ if clumps[i, j, k] != 0:
51
+ clump_id = int(
52
+ clumps[i, j, k]
53
+ ) # clump_id is the clump number ranging from 1 to total_clumps_detected
54
+ summed_overdensity_per_clump[clump_id - 1] += delta[i, j, k]
55
+ num_cells_per_clump[clump_id - 1] += 1
56
+
57
+ return summed_overdensity_per_clump / num_cells_per_clump
34
58
 
35
59
  for i, S_th in enumerate(signature_thresholds):
36
60
  # Identify Clumps with S > S_th
37
61
  _clusbool = max_sigs[:, :, :, 0] > S_th
62
+
38
63
  clumps = skimage.measure.label(
39
- _clusbool
64
+ _clusbool.astype(int)
40
65
  ) # an array where 0 is background and 1, 2, 3, ... are the clumps
41
- total_clumps_detected = np.max(clumps)
66
+ averaged_overdensity_per_clump = calc_virialized_fraction(clumps)
42
67
 
43
- num_clumps_virialized = np.sum(
44
- list(
45
- map(
46
- functools.partial(
47
- check_virialized, delta=delta, clumps=clumps, Δ=Δ
48
- ),
49
- range(1, total_clumps_detected + 1),
50
- )
51
- )
52
- ) # number of clumps that are virialized
53
-
54
- # Calculate the number of virialized clumps
55
- virialized_fractions[i] = num_clumps_virialized / total_clumps_detected
68
+ virialized_fractions[i] = np.sum(averaged_overdensity_per_clump > Δ) / np.max(
69
+ clumps
70
+ )
56
71
 
57
72
  S_th = signature_thresholds[np.abs(virialized_fractions - 0.5).argmin()]
58
73
  clusbool = max_sigs[:, :, :, 0] > S_th
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