flipcosmo 1.0.0__tar.gz → 1.2.1__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 (132) hide show
  1. flipcosmo-1.2.1/PKG-INFO +78 -0
  2. flipcosmo-1.2.1/docs/conf.py +154 -0
  3. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/__init__.py +4 -11
  4. flipcosmo-1.2.1/flip/covariance/__init__.py +14 -0
  5. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/__init__.py +1 -5
  6. {flipcosmo-1.0.0/flip/covariance/adamsblake17plane → flipcosmo-1.2.1/flip/covariance/analytical/adamsblake17}/coefficients.py +1 -1
  7. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/adamsblake17/fisher_terms.py +1 -1
  8. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/adamsblake17/flip_terms.py +0 -1
  9. {flipcosmo-1.0.0/flip/covariance/adamsblake17 → flipcosmo-1.2.1/flip/covariance/analytical/adamsblake17plane}/coefficients.py +1 -1
  10. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/adamsblake17plane/fisher_terms.py +1 -1
  11. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/adamsblake17plane/flip_terms.py +0 -1
  12. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/adamsblake17plane/generator.py +103 -19
  13. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/adamsblake20/coefficients.py +1 -1
  14. {flipcosmo-1.0.0/flip/covariance/ravouxcarreres → flipcosmo-1.2.1/flip/covariance/analytical/adamsblake20}/fisher_terms.py +1 -1
  15. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/adamsblake20/flip_terms.py +0 -1
  16. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/carreres23/coefficients.py +1 -4
  17. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/carreres23/fisher_terms.py +1 -1
  18. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/carreres23/flip_terms.py +0 -1
  19. flipcosmo-1.2.1/flip/covariance/analytical/carreres23/generator.py +198 -0
  20. flipcosmo-1.2.1/flip/covariance/analytical/genericzdep/__init__.py +5 -0
  21. flipcosmo-1.2.1/flip/covariance/analytical/genericzdep/coefficients.py +53 -0
  22. flipcosmo-1.2.1/flip/covariance/analytical/genericzdep/flip_terms.py +99 -0
  23. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/lai22/coefficients.py +2 -3
  24. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/lai22/fisher_terms.py +1 -1
  25. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/lai22/flip_terms.py +0 -1
  26. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/lai22/generator.py +263 -58
  27. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/lai22/symbolic.py +55 -19
  28. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/ravouxcarreres/coefficients.py +1 -1
  29. {flipcosmo-1.0.0/flip/covariance/adamsblake20 → flipcosmo-1.2.1/flip/covariance/analytical/ravouxcarreres}/fisher_terms.py +1 -1
  30. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/ravouxcarreres/flip_terms.py +0 -1
  31. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/ravouxnoanchor25/coefficients.py +3 -2
  32. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/ravouxnoanchor25/fisher_terms.py +1 -1
  33. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/ravouxnoanchor25/flip_terms.py +0 -9
  34. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/rcrk24/coefficients.py +6 -6
  35. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/rcrk24/fisher_terms.py +7 -9
  36. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/rcrk24/flip_terms.py +0 -8
  37. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/covariance/contraction.py +82 -40
  38. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/covariance/cov_utils.py +89 -81
  39. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/covariance/covariance.py +172 -141
  40. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/covariance/emulators/__init__.py +1 -1
  41. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/covariance/emulators/generator.py +73 -3
  42. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/covariance/emulators/gpmatrix.py +40 -1
  43. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/covariance/emulators/nnmatrix.py +57 -1
  44. flipcosmo-1.2.1/flip/covariance/emulators/skgpmatrix.py +125 -0
  45. flipcosmo-1.2.1/flip/covariance/fisher.py +307 -0
  46. {flipcosmo-1.0.0/flip → flipcosmo-1.2.1/flip/covariance}/fit_utils.py +185 -10
  47. {flipcosmo-1.0.0/flip → flipcosmo-1.2.1/flip/covariance}/fitter.py +151 -125
  48. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/covariance/generator.py +82 -106
  49. {flipcosmo-1.0.0/flip → flipcosmo-1.2.1/flip/covariance}/likelihood.py +286 -64
  50. {flipcosmo-1.0.0/flip → flipcosmo-1.2.1/flip/covariance}/plot_utils.py +79 -4
  51. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/covariance/symbolic.py +89 -44
  52. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/data/__init__.py +1 -1
  53. flipcosmo-1.2.1/flip/data/data_density.parquet +0 -0
  54. flipcosmo-1.2.1/flip/data/data_velocity.parquet +0 -0
  55. flipcosmo-1.0.0/flip/data/grid_window_m.parquet → flipcosmo-1.2.1/flip/data/data_window_density.parquet +0 -0
  56. {flipcosmo-1.0.0/flip → flipcosmo-1.2.1/flip/data}/gridding.py +125 -130
  57. flipcosmo-1.2.1/flip/data/load_data_test.py +102 -0
  58. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/data/power_spectrum_mm.txt +2 -2
  59. flipcosmo-1.0.0/flip/data/power_spectrum_tt.txt → flipcosmo-1.2.1/flip/data/power_spectrum_mt.txt +2 -2
  60. flipcosmo-1.0.0/flip/data/power_spectrum_mt.txt → flipcosmo-1.2.1/flip/data/power_spectrum_tt.txt +2 -2
  61. flipcosmo-1.2.1/flip/data/test_covariance_reference_values.json +145 -0
  62. flipcosmo-1.2.1/flip/data/test_e2e_reference_values.json +14 -0
  63. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/data_vector/basic.py +118 -101
  64. flipcosmo-1.2.1/flip/data_vector/cosmo_utils.py +24 -0
  65. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/data_vector/galaxypv_vectors.py +58 -94
  66. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/data_vector/snia_vectors.py +60 -3
  67. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/data_vector/vector_utils.py +47 -1
  68. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/power_spectra/class_engine.py +36 -1
  69. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/power_spectra/cosmoprimo_engine.py +37 -2
  70. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/power_spectra/generator.py +47 -25
  71. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/power_spectra/models.py +30 -31
  72. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/power_spectra/pyccl_engine.py +36 -1
  73. flipcosmo-1.2.1/flip/simulation/__init__.py +0 -0
  74. flipcosmo-1.2.1/flip/utils.py +199 -0
  75. flipcosmo-1.2.1/flipcosmo.egg-info/PKG-INFO +78 -0
  76. flipcosmo-1.2.1/flipcosmo.egg-info/SOURCES.txt +216 -0
  77. flipcosmo-1.2.1/flipcosmo.egg-info/top_level.txt +7 -0
  78. flipcosmo-1.2.1/pyproject.toml +59 -0
  79. flipcosmo-1.2.1/scripts/flip_compute_correlation_model.py +70 -0
  80. flipcosmo-1.2.1/scripts/flip_compute_power_spectra.py +50 -0
  81. flipcosmo-1.2.1/scripts/flip_fisher_forecast_velocity.py +70 -0
  82. flipcosmo-1.2.1/scripts/flip_fisher_rcrk24.py +164 -0
  83. flipcosmo-1.2.1/scripts/flip_launch_minuit_density_fit.py +91 -0
  84. flipcosmo-1.2.1/scripts/flip_launch_minuit_full_fit.py +117 -0
  85. flipcosmo-1.2.1/scripts/flip_launch_minuit_velocity_fit.py +78 -0
  86. flipcosmo-1.2.1/scripts/flip_launch_minuit_velocity_fit_full.py +107 -0
  87. flipcosmo-1.2.1/scripts/flip_launch_minuit_velocity_fit_interpolation.py +93 -0
  88. flipcosmo-1.2.1/setup.cfg +4 -0
  89. flipcosmo-1.2.1/test/refresh_reference_values.py +43 -0
  90. flipcosmo-1.2.1/test/test_covariance_assembly.py +102 -0
  91. flipcosmo-1.2.1/test/test_covariance_reference_values.py +125 -0
  92. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/test/test_covariance_utils.py +0 -1
  93. flipcosmo-1.2.1/test/test_e2e_density.py +50 -0
  94. flipcosmo-1.2.1/test/test_e2e_joint.py +65 -0
  95. flipcosmo-1.2.1/test/test_e2e_velocity.py +53 -0
  96. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/test/test_likelihood_inversions.py +1 -2
  97. flipcosmo-1.0.0/PKG-INFO +0 -32
  98. flipcosmo-1.0.0/flip/covariance/carreres23/generator.py +0 -132
  99. flipcosmo-1.0.0/flip/data/density_data.parquet +0 -0
  100. flipcosmo-1.0.0/flip/data/velocity_data.parquet +0 -0
  101. flipcosmo-1.0.0/flip/data_vector/cosmo_utils.py +0 -6
  102. flipcosmo-1.0.0/flip/fisher.py +0 -190
  103. flipcosmo-1.0.0/flip/utils.py +0 -228
  104. flipcosmo-1.0.0/flipcosmo.egg-info/PKG-INFO +0 -32
  105. flipcosmo-1.0.0/flipcosmo.egg-info/SOURCES.txt +0 -94
  106. flipcosmo-1.0.0/flipcosmo.egg-info/top_level.txt +0 -1
  107. flipcosmo-1.0.0/setup.cfg +0 -43
  108. flipcosmo-1.0.0/setup.py +0 -63
  109. flipcosmo-1.0.0/test/test_covariance_assembly.py +0 -92
  110. flipcosmo-1.0.0/test/test_covariance_reference_values.py +0 -138
  111. flipcosmo-1.0.0/test/test_e2e_density.py +0 -57
  112. flipcosmo-1.0.0/test/test_e2e_joint.py +0 -76
  113. flipcosmo-1.0.0/test/test_e2e_velocity.py +0 -65
  114. flipcosmo-1.0.0/test/test_models_coverage.py +0 -126
  115. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/LICENSE +0 -0
  116. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/README.md +0 -0
  117. /flipcosmo-1.0.0/flip/config.py → /flipcosmo-1.2.1/flip/_config.py +0 -0
  118. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/adamsblake17/__init__.py +0 -0
  119. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/adamsblake17plane/__init__.py +0 -0
  120. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/adamsblake20/__init__.py +0 -0
  121. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/carreres23/__init__.py +0 -0
  122. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/lai22/__init__.py +0 -0
  123. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/lai22/h_terms.py +0 -0
  124. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/ravouxcarreres/__init__.py +0 -0
  125. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/ravouxcarreres/flip_terms_lmax.py +0 -0
  126. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/ravouxnoanchor25/__init__.py +0 -0
  127. {flipcosmo-1.0.0/flip/covariance → flipcosmo-1.2.1/flip/covariance/analytical}/rcrk24/__init__.py +0 -0
  128. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/data/style.mplstyle +0 -0
  129. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/data_vector/__init__.py +0 -0
  130. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flip/power_spectra/__init__.py +0 -0
  131. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flipcosmo.egg-info/dependency_links.txt +0 -0
  132. {flipcosmo-1.0.0 → flipcosmo-1.2.1}/flipcosmo.egg-info/requires.txt +0 -0
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: flipcosmo
3
+ Version: 1.2.1
4
+ Summary: Field Level Inference Package
5
+ Author-email: Corentin Ravoux <corentin.ravoux.research@gmail.com>, Bastien Carreres <bastien.carreres@duke.edu>
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: pandas
11
+ Requires-Dist: numpy
12
+ Requires-Dist: scipy>=1.12
13
+ Requires-Dist: matplotlib
14
+ Requires-Dist: importlib-metadata
15
+ Requires-Dist: emcee
16
+ Requires-Dist: iminuit
17
+ Requires-Dist: astropy
18
+ Requires-Dist: mpmath
19
+ Provides-Extra: docs
20
+ Requires-Dist: markdown; extra == "docs"
21
+ Requires-Dist: sphinx>=5.2.3; extra == "docs"
22
+ Requires-Dist: sphinx-markdown-tables>=0.0.15; extra == "docs"
23
+ Requires-Dist: numpydoc; extra == "docs"
24
+ Requires-Dist: sphinx_book_theme; extra == "docs"
25
+ Requires-Dist: myst-parser; extra == "docs"
26
+ Requires-Dist: sphinx-copybutton; extra == "docs"
27
+ Requires-Dist: sphinx-design; extra == "docs"
28
+ Requires-Dist: sphinx-inline-tabs; extra == "docs"
29
+ Requires-Dist: sphinx-tabs; extra == "docs"
30
+ Requires-Dist: sphinx-autoapi; extra == "docs"
31
+ Dynamic: license-file
32
+
33
+ <img src="docs/_static/flip_logo.webp" width=350>
34
+
35
+ # flip: Field Level Inference Package
36
+
37
+ flip is a Python package that uses the maximum likelihood method to fit the growth rate based on the velocity and density fields. The first part of the software is the computation of a covariance matrix from a model power spectrum and the considered coordinates. This part is generalized to work for any linear power spectrum models, both for velocities, densities, and cross-terms, and it is optimized with Hankel transform for any model. In the second part, the covariance is used to create a likelihood by multiplying it by velocities or densities. Finally, this package includes some integrated fitters such as Minuit and MCMC (with emcee) to fit the growth rate of structures.
38
+
39
+
40
+ [![Documentation Status](https://readthedocs.org/projects/flip/badge/?version=latest)](https://flip.readthedocs.io/en/latest/?badge=latest)
41
+
42
+ ## Quick install
43
+ ```bash
44
+ git clone https://github.com/corentinravoux/flip.git
45
+ cd flip
46
+ pip install .
47
+ ```
48
+ For now, the package requires you to install manually cosmoprimo: pip install git+https://github.com/cosmodesi/cosmoprimo
49
+
50
+
51
+ ## Required packages
52
+
53
+ Mandatory: numpy, scipy, matplotlib, [cosmoprimo](https://github.com/adematti/cosmoprimo), iminuit, emcee, sympy
54
+
55
+ Optional: classy, pyccl, pypower, GPy, tensorflow
56
+
57
+ ## Examples
58
+
59
+ For an example with velocity fit check out: <a target="_blank" href="https://colab.research.google.com/github/corentinravoux/flip/blob/main/notebook/fit_velocity.ipynb">
60
+ <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
61
+ </a>
62
+
63
+ For density only: <a target="_blank" href="https://colab.research.google.com/github/corentinravoux/flip/blob/main/notebook/fit_density.ipynb">
64
+ <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
65
+ </a>
66
+
67
+ For a joint fit: <a target="_blank" href="https://colab.research.google.com/github/corentinravoux/flip/blob/main/notebook/fit_joint.ipynb">
68
+ <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
69
+ </a>
70
+
71
+ ## Need help?
72
+ Documentation available on [ReadTheDoc](https://flip.readthedocs.io/)
73
+
74
+ ## How to cite
75
+
76
+ The full description of the core concepts of this package is given [here](https://arxiv.org/abs/2501.16852).
77
+ This package was started on the previous work of [@bastiencarreres](https://github.com/bastiencarreres), detail in [this article](https://arxiv.org/abs/2303.01198).
78
+ Please cite both paper when using the package.
@@ -0,0 +1,154 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # This file only contains a selection of the most common options. For a full
4
+ # list see the documentation:
5
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
6
+
7
+ # -- Path setup --------------------------------------------------------------
8
+
9
+ # If extensions (or modules to document with autodoc) are in another directory,
10
+ # add these directories to sys.path here. If the directory is relative to the
11
+ # documentation root, use os.path.abspath to make it absolute, like shown here.
12
+ #
13
+ # import os
14
+ # import sys
15
+ # sys.path.insert(0, os.path.abspath('.'))
16
+
17
+
18
+ # -- Project information -----------------------------------------------------
19
+ import sys
20
+ import os
21
+ import numpy
22
+ sys.path.insert(0, os.path.abspath('..'))
23
+ import flip
24
+
25
+ project = 'flip'
26
+ copyright = '2023, C. Ravoux, B. Carreres'
27
+ author = 'C. Ravoux, B. Carreres'
28
+
29
+ # The full version, including alpha/beta/rc tags
30
+ release = flip.__version__
31
+
32
+ intersphinx_mapping = {
33
+ 'python': ('https://docs.python.org/3/', None),
34
+ 'numpy': ('https://docs.scipy.org/doc/numpy/', None),
35
+ 'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None),
36
+ 'astropy': ('http://docs.astropy.org/en/stable/', None),
37
+ 'sncosmo': ('https://sncosmo.readthedocs.io/en/stable/', None),
38
+ 'pandas': ('https://pandas.pydata.org/docs/', None)}
39
+
40
+ # -- General configuration ---------------------------------------------------
41
+
42
+ # Add any Sphinx extension module names here, as strings. They can be
43
+ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
44
+ # ones.
45
+
46
+ extensions = ['myst_parser', 'sphinx.ext.napoleon', 'sphinx_markdown_tables', 'sphinx.ext.autosectionlabel',
47
+ 'sphinx.ext.linkcode', 'sphinx.ext.intersphinx', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary']
48
+ extensions.append('autoapi.extension')
49
+
50
+ # Auto-API config
51
+ autoapi_dirs = ['../flip', '../flip/covariance']
52
+
53
+ def skip_util_classes(app, what, name, obj, skip, options):
54
+ if name == "__init__":
55
+ skip = False
56
+ return skip
57
+
58
+ def setup(sphinx):
59
+ sphinx.connect("autoapi-skip-member", skip_util_classes)
60
+
61
+
62
+
63
+ napoleon_google_docstring = True
64
+ myst_enable_extensions = ["dollarmath"]
65
+ myst_dmath_double_inline = True
66
+
67
+
68
+ autosectionlabel_prefix_document = True
69
+ # Add any paths that contain templates here, relative to this directory.
70
+ autosummary_generate = True
71
+
72
+ # List of patterns, relative to source directory, that match files and
73
+ # directories to ignore when looking for source files.
74
+ # This pattern also affects html_static_path and html_extra_path.
75
+ exclude_patterns = ['_build', '_templates']
76
+
77
+ source_suffix = {
78
+ '.rst': 'restructuredtext',
79
+ '.txt': 'markdown',
80
+ '.md': 'markdown',
81
+ }
82
+ # -- Options for HTML output -------------------------------------------------
83
+
84
+ # The theme to use for HTML and HTML Help pages. See the documentation for
85
+ # a list of builtin themes.
86
+ #
87
+ html_theme = "sphinx_book_theme"
88
+
89
+ # Add any paths that contain custom static files (such as style sheets) here,
90
+ # relative to this directory. They are copied after the builtin static files,
91
+ # so a file named "default.css" will overwrite the builtin "default.css".
92
+ html_static_path = ['_static']
93
+
94
+ html_logo = "_static/flip_logo.webp"
95
+ html_title = "FLIP"
96
+ html_theme_options = {
97
+ "icon_links": [
98
+ {
99
+ # Label for this link
100
+ "name": "GitHub",
101
+ # URL where the link will redirect
102
+ "url": "https://github.com/corentinravoux/flip", # required
103
+ # Icon class (if "type": "fontawesome"), or path to local image (if "type": "local")
104
+ "icon": "fa-brands fa-github",
105
+ # The type of image to be used (see below for details)
106
+ "type": "fontawesome",
107
+ }
108
+ ]
109
+ }
110
+
111
+ import inspect
112
+ from os.path import relpath
113
+
114
+
115
+ # Copied on sncosmo documentation
116
+ def linkcode_resolve(domain, info):
117
+ """Determine the URL corresponding to Python object."""
118
+ if domain != 'py':
119
+ return None
120
+
121
+ modname = info['module']
122
+ fullname = info['fullname']
123
+
124
+ submod = sys.modules.get(modname)
125
+ if submod is None:
126
+ return None
127
+
128
+ obj = submod
129
+ for part in fullname.split('.'):
130
+ try:
131
+ obj = getattr(obj, part)
132
+ except:
133
+ return None
134
+
135
+ try:
136
+ fn = inspect.getsourcefile(obj)
137
+ except:
138
+ fn = None
139
+ if not fn:
140
+ return None
141
+
142
+ try:
143
+ source, lineno = inspect.findsource(obj)
144
+ except:
145
+ lineno = None
146
+
147
+ if lineno:
148
+ linespec = "#L%d" % (lineno + 1)
149
+ else:
150
+ linespec = ""
151
+
152
+ fn = relpath(fn, start=flip.__flip_dir_path__)
153
+
154
+ return "https://github.com/corentinravoux/flip/tree/main/flip/%s%s" % (fn, linespec)
@@ -5,16 +5,8 @@ import os
5
5
  from flip.utils import create_log
6
6
 
7
7
  log = create_log()
8
- from . import (
9
- covariance,
10
- data_vector,
11
- fisher,
12
- fitter,
13
- gridding,
14
- likelihood,
15
- power_spectra,
16
- utils,
17
- )
8
+ from . import covariance, data, data_vector, power_spectra, utils
9
+ from .utils import __secret_logo__
18
10
 
19
11
  try:
20
12
  import jax
@@ -23,5 +15,6 @@ try:
23
15
  except:
24
16
  log.add("Jax is not available, loading numpy and scipy instead")
25
17
 
26
- __version__ = "1.0.0"
27
18
  __flip_dir_path__ = os.path.dirname(__file__)
19
+
20
+ __version__ = "1.2.1"
@@ -0,0 +1,14 @@
1
+ """Init file of the flip.covariance package."""
2
+
3
+ from . import (
4
+ analytical,
5
+ contraction,
6
+ cov_utils,
7
+ emulators,
8
+ fisher,
9
+ fitter,
10
+ generator,
11
+ likelihood,
12
+ symbolic,
13
+ )
14
+ from .covariance import CovMatrix
@@ -1,15 +1,11 @@
1
- """Init file of the flip.covariance package."""
2
-
3
1
  from . import (
4
2
  adamsblake17,
5
3
  adamsblake17plane,
6
4
  adamsblake20,
7
5
  carreres23,
8
- cov_utils,
9
- emulators,
6
+ genericzdep,
10
7
  lai22,
11
8
  ravouxcarreres,
12
9
  ravouxnoanchor25,
13
10
  rcrk24,
14
11
  )
15
- from .covariance import CovMatrix
@@ -2,7 +2,7 @@ def get_coefficients(
2
2
  parameter_values_dict,
3
3
  model_kind,
4
4
  variant=None,
5
- redshift_dict=None,
5
+ covariance_prefactor_dict=None,
6
6
  ):
7
7
  coefficients_dict = {}
8
8
  if model_kind in ["density", "full", "density_velocity"]:
@@ -5,7 +5,7 @@ def get_partial_derivative_coefficients(
5
5
  model_kind,
6
6
  parameter_values_dict,
7
7
  variant=None,
8
- redshift_dict=None,
8
+ covariance_prefactor_dict=None,
9
9
  ):
10
10
  if model_kind == "density":
11
11
  return get_partial_derivative_coefficients_density(
@@ -74,5 +74,4 @@ dictionary_subterms = {
74
74
  "vv_0_2": 1,
75
75
  }
76
76
  multi_index_model = False
77
- redshift_dependent_model = False
78
77
  regularize_M_terms = None
@@ -2,7 +2,7 @@ def get_coefficients(
2
2
  parameter_values_dict,
3
3
  model_kind,
4
4
  variant=None,
5
- redshift_dict=None,
5
+ covariance_prefactor_dict=None,
6
6
  ):
7
7
  coefficients_dict = {}
8
8
  if model_kind in ["density", "full", "density_velocity"]:
@@ -5,7 +5,7 @@ def get_partial_derivative_coefficients(
5
5
  model_kind,
6
6
  parameter_values_dict,
7
7
  variant=None,
8
- redshift_dict=None,
8
+ covariance_prefactor_dict=None,
9
9
  ):
10
10
  if model_kind == "density":
11
11
  return get_partial_derivative_coefficients_density(
@@ -71,5 +71,4 @@ dictionary_subterms = {
71
71
  "vv_0_2": 1,
72
72
  }
73
73
  multi_index_model = False
74
- redshift_dependent_model = False
75
74
  regularize_M_terms = None
@@ -8,7 +8,17 @@ from flip.covariance import cov_utils
8
8
 
9
9
 
10
10
  def angle_between(ra_0, ra_1, dec_0, dec_1):
11
- """Compute cos of the angle between r0 and r1."""
11
+ """Compute cos of the angle between two sky directions.
12
+
13
+ Args:
14
+ ra_0: Right ascension of first object (radians).
15
+ ra_1: Right ascension of second object (radians).
16
+ dec_0: Declination of first object (radians).
17
+ dec_1: Declination of second object (radians).
18
+
19
+ Returns:
20
+ Cosine of the angular separation.
21
+ """
12
22
  cos_alpha = np.cos(ra_1 - ra_0) * np.cos(dec_0) * np.cos(dec_1) + np.sin(
13
23
  dec_0
14
24
  ) * np.sin(dec_1)
@@ -16,12 +26,31 @@ def angle_between(ra_0, ra_1, dec_0, dec_1):
16
26
 
17
27
 
18
28
  def separation(r_0, r_1, cos_alpha):
19
- """Compute separation between r_0 and r_1."""
29
+ """Compute comoving separation given distances and angular cosine.
30
+
31
+ Args:
32
+ r_0: Comoving distance of first object.
33
+ r_1: Comoving distance of second object.
34
+ cos_alpha: Cosine of angular separation.
35
+
36
+ Returns:
37
+ Scalar separation between points.
38
+ """
20
39
  return np.sqrt(r_0**2 + r_1**2 - 2 * r_0 * r_1 * cos_alpha)
21
40
 
22
41
 
23
42
  def window_vv(r_0, r_1, cos_alpha, sep, j0kr, j2kr):
24
- """Note: here, the bisector angle definition is used to compute"""
43
+ """Wide-angle window for vv using bisector definition.
44
+
45
+ Args:
46
+ r_0, r_1: Comoving distances of the two objects.
47
+ cos_alpha: Cosine of angle between directions.
48
+ sep: Comoving separation.
49
+ j0kr, j2kr: Spherical Bessel terms evaluated on ``k*sep``.
50
+
51
+ Returns:
52
+ Window values per k contributing to vv covariance integral.
53
+ """
25
54
  win = 1 / 3 * (j0kr + j2kr)
26
55
  alpha = np.arccos(np.clip(cos_alpha, -1.0, 1.0))
27
56
  phi = cov_utils.compute_phi_bisector_theorem(sep, alpha, r_0, r_1)
@@ -30,7 +59,17 @@ def window_vv(r_0, r_1, cos_alpha, sep, j0kr, j2kr):
30
59
 
31
60
 
32
61
  def window_vg(r_0, r_1, cos_alpha, sep, j1kr):
33
- """Note: here, the bisector angle definition is used to compute"""
62
+ """Wide-angle window for gv using bisector definition.
63
+
64
+ Args:
65
+ r_0, r_1: Comoving distances of the two objects.
66
+ cos_alpha: Cosine of angle between directions.
67
+ sep: Comoving separation.
68
+ j1kr: Spherical Bessel term ``j_1(k*sep)``.
69
+
70
+ Returns:
71
+ Window values per k contributing to gv covariance integral.
72
+ """
34
73
  alpha = np.arccos(np.clip(cos_alpha, -1.0, 1.0))
35
74
  phi = cov_utils.compute_phi_bisector_theorem(sep, alpha, r_0, r_1)
36
75
  win = j1kr * np.cos(phi)
@@ -38,11 +77,31 @@ def window_vg(r_0, r_1, cos_alpha, sep, j1kr):
38
77
 
39
78
 
40
79
  def intp(win, k, pk):
80
+ """Integrate window times spectrum over k using trapezoidal rule.
81
+
82
+ Args:
83
+ win: Window array per k.
84
+ k: Wavenumber grid.
85
+ pk: Spectrum values at k.
86
+
87
+ Returns:
88
+ Scalar integral value.
89
+ """
41
90
  pint = win.T * pk
42
91
  return np.trapz(pint, x=k)
43
92
 
44
93
 
45
94
  def compute_coef_gg(k, pk, coord):
95
+ """Coefficient contributing to gg covariance for a single pair.
96
+
97
+ Args:
98
+ k: Wavenumber grid.
99
+ pk: Matter spectrum values at k.
100
+ coord: Tuple/list ``(ra_i, ra_j, dec_i, dec_j, r_i, r_j)``.
101
+
102
+ Returns:
103
+ Scalar integral value for gg.
104
+ """
46
105
  cos = angle_between(coord[0], coord[1], coord[2], coord[3])
47
106
  sep = separation(coord[4], coord[5], cos)
48
107
  ksep = np.outer(k, sep)
@@ -52,6 +111,13 @@ def compute_coef_gg(k, pk, coord):
52
111
 
53
112
 
54
113
  def compute_coef_gv(k, pk, coord):
114
+ """Coefficient contributing to gv covariance for a single pair.
115
+
116
+ Args mirror those of ``compute_coef_gg`` but using cross-spectrum and window.
117
+
118
+ Returns:
119
+ Scalar integral value for gv.
120
+ """
55
121
  cos = angle_between(coord[0], coord[1], coord[2], coord[3])
56
122
  sep = separation(coord[4], coord[5], cos)
57
123
  ksep = np.outer(k, sep)
@@ -62,6 +128,13 @@ def compute_coef_gv(k, pk, coord):
62
128
 
63
129
 
64
130
  def compute_coef_vv(k, pk, coord):
131
+ """Coefficient contributing to vv covariance for a single pair.
132
+
133
+ Args mirror those of ``compute_coef_gg`` but using velocity spectrum and window.
134
+
135
+ Returns:
136
+ Scalar integral value for vv.
137
+ """
65
138
  cos = angle_between(coord[0], coord[1], coord[2], coord[3])
66
139
  sep = separation(coord[4], coord[5], cos)
67
140
  ksep = np.outer(k, sep)
@@ -81,6 +154,18 @@ def covariance_vv(
81
154
  size_batch=100_000,
82
155
  number_worker=8,
83
156
  ):
157
+ """Compute velocity-velocity covariance (plane-parallel wide-angle bisector).
158
+
159
+ Args:
160
+ ra_v, dec_v, rcomov_v: Velocity tracer coordinates and distances.
161
+ wavenumber: Wavenumber grid for velocity spectrum.
162
+ power_spectrum: Spectrum values at wavenumber.
163
+ size_batch: Number of pairs per batch.
164
+ number_worker: Number of parallel workers.
165
+
166
+ Returns:
167
+ Flattened covariance vector with variance at index 0.
168
+ """
84
169
  N = len(ra_v)
85
170
  n_task = int((N * (N + 1)) / 2) - N
86
171
  batches = []
@@ -114,6 +199,10 @@ def covariance_gv(
114
199
  size_batch=100_000,
115
200
  number_worker=8,
116
201
  ):
202
+ """Compute density-velocity covariance (plane-parallel wide-angle bisector).
203
+
204
+ Returns flattened covariance vector with variance at index 0.
205
+ """
117
206
  number_objects_g = len(ra_g)
118
207
  number_objects_v = len(ra_v)
119
208
 
@@ -147,6 +236,7 @@ def covariance_gg(
147
236
  size_batch=100_000,
148
237
  number_worker=8,
149
238
  ):
239
+ """Compute density-density covariance (plane-parallel)."""
150
240
  N = len(ra_g)
151
241
  n_task = int((N * (N + 1)) / 2) - N
152
242
  batches = []
@@ -176,23 +266,19 @@ def generate_covariance(
176
266
  coordinates_density=None,
177
267
  **kwargs,
178
268
  ):
179
- """
180
- The generate_covariance function generates the covariance matrix for a given model type, power spectrum, and coordinates.
269
+ """Generate covariance blocks using Adams & Blake (2017) plane approximation.
270
+
271
+ Wide-angle definition uses the bisector. Supports ``gg``, ``vv``, and ``gv``.
181
272
 
182
273
  Args:
183
- model_kind: Determine which covariance matrices are generated, and the coordinates_density and coordinates_velocity parameters are used to generate the covariance matrices
184
- power_spectrum_dict: Pass the power spectrum to the function
185
- coordinates_velocity: Define the coordinates of the velocity field
186
- coordinates_density: Define the coordinates of the density field
187
- **kwargs: Pass keyword arguments to the function
188
- : Generate the covariance matrix for a given model
189
- The wide angle definition is bisector.
274
+ model_kind: One of ``"density"``, ``"velocity"``, ``"full"``, ``"density_velocity"``.
275
+ power_spectrum_dict: Dict providing required spectra grids and values.
276
+ coordinates_velocity: Tuple ``(ra, dec, rcom)`` for velocity tracers.
277
+ coordinates_density: Tuple ``(ra, dec, rcom)`` for density tracers.
278
+ **kwargs: Forwarded to low-level covariance functions (batch/workers).
190
279
 
191
280
  Returns:
192
- A dictionary of covariance matrices
193
-
194
- Doc Author:
195
- Trelent
281
+ Tuple ``(covariance_dict, number_densities, number_velocities, los_definition)``.
196
282
  """
197
283
  cov_utils.check_generator_need(
198
284
  model_kind,
@@ -253,11 +339,9 @@ def generate_covariance(
253
339
  )
254
340
 
255
341
  los_definition = "bisector"
256
- redshift_dict = None
257
342
  return (
258
343
  covariance_dict,
259
344
  number_densities,
260
345
  number_velocities,
261
346
  los_definition,
262
- redshift_dict,
263
347
  )
@@ -2,7 +2,7 @@ def get_coefficients(
2
2
  parameter_values_dict,
3
3
  model_kind,
4
4
  variant=None,
5
- redshift_dict=None,
5
+ covariance_prefactor_dict=None,
6
6
  ):
7
7
  coefficients_dict = {}
8
8
  if model_kind in ["density", "full", "density_velocity"]:
@@ -5,7 +5,7 @@ def get_partial_derivative_coefficients(
5
5
  model_kind,
6
6
  parameter_values_dict,
7
7
  variant=None,
8
- redshift_dict=None,
8
+ covariance_prefactor_dict=None,
9
9
  ):
10
10
  if model_kind == "density":
11
11
  return get_partial_derivative_coefficients_density(
@@ -342,5 +342,4 @@ dictionary_subterms = {
342
342
  "vv_0_2": 1,
343
343
  }
344
344
  multi_index_model = False
345
- redshift_dependent_model = False
346
345
  regularize_M_terms = {"gg": "mpmath", "gv": "mpmath", "vv": None}
@@ -1,11 +1,8 @@
1
- import numpy as np
2
-
3
-
4
1
  def get_coefficients(
5
2
  parameter_values_dict,
6
3
  model_kind,
7
4
  variant=None,
8
- redshift_dict=None,
5
+ covariance_prefactor_dict=None,
9
6
  ):
10
7
  coefficients_dict = {}
11
8
  coefficients_dict["vv"] = [parameter_values_dict["fs8"] ** 2]
@@ -5,7 +5,7 @@ def get_partial_derivative_coefficients(
5
5
  model_kind,
6
6
  parameter_values_dict,
7
7
  variant=None,
8
- redshift_dict=None,
8
+ covariance_prefactor_dict=None,
9
9
  ):
10
10
  if variant == "growth_index":
11
11
  partial_coefficients_dict = {
@@ -42,5 +42,4 @@ dictionary_terms = {"vv": ["0"]}
42
42
  dictionary_lmax = {"vv": [2]}
43
43
  dictionary_subterms = {"vv_0_0": 1, "vv_0_1": 0, "vv_0_2": 1}
44
44
  multi_index_model = False
45
- redshift_dependent_model = False
46
45
  regularize_M_terms = None