pybinny 1.2.0__tar.gz → 2.0.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.
- {pybinny-1.2.0/src/pybinny.egg-info → pybinny-2.0.0}/PKG-INFO +2 -2
- {pybinny-1.2.0 → pybinny-2.0.0}/pyproject.toml +3 -3
- pybinny-2.0.0/src/binny/__init__.py +21 -0
- pybinny-2.0.0/src/binny/analysis/__init__.py +123 -0
- {pybinny-1.2.0/src/binny/tomography → pybinny-2.0.0/src/binny/analysis}/combinations.py +3 -0
- {pybinny-1.2.0/src/binny/tomography → pybinny-2.0.0/src/binny/analysis}/comparison.py +1 -1
- {pybinny-1.2.0/src/binny/tomography → pybinny-2.0.0/src/binny/analysis}/stats.py +13 -9
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/binning/__init__.py +27 -11
- pybinny-2.0.0/src/binny/binning/core.py +91 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/binning/edges.py +0 -22
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/binning/photoz.py +1 -190
- pybinny-2.0.0/src/binny/binning/specz.py +538 -0
- pybinny-2.0.0/src/binny/calibration/__init__.py +43 -0
- {pybinny-1.2.0/src/binny/binning → pybinny-2.0.0/src/binny/calibration}/photoz_fitting.py +247 -10
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/nz/__init__.py +16 -34
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/nz/luminosity_function_distribution.py +2 -2
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/nz/models.py +3 -3
- pybinny-2.0.0/src/binny/nz/sampling.py +213 -0
- pybinny-2.0.0/src/binny/style/__init__.py +19 -0
- {pybinny-1.2.0/src/binny/utils → pybinny-2.0.0/src/binny/style}/colors.py +17 -18
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/config_utils.py +1 -494
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/euclid_survey_specs.yaml +1 -1
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/example_full_specz.yaml +1 -1
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/survey_presets.py +2 -1
- pybinny-2.0.0/src/binny/tomography/__init__.py +16 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/tomography/builders.py +13 -42
- pybinny-2.0.0/src/binny/tomography/core.py +297 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/tomography/predefined.py +23 -20
- pybinny-2.0.0/src/binny/tomography/specs.py +497 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/io.py +1 -1
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/metadata.py +81 -14
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/normalization.py +91 -51
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/pairwise_metrics.py +1 -169
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/types.py +2 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/validators.py +59 -0
- {pybinny-1.2.0 → pybinny-2.0.0/src/pybinny.egg-info}/PKG-INFO +2 -2
- {pybinny-1.2.0 → pybinny-2.0.0}/src/pybinny.egg-info/SOURCES.txt +30 -22
- pybinny-1.2.0/tests/test_tomography_combinations.py → pybinny-2.0.0/tests/test_analysis_combinations.py +8 -8
- pybinny-1.2.0/tests/test_tomography_comparison.py → pybinny-2.0.0/tests/test_analysis_comparison.py +1 -1
- pybinny-1.2.0/tests/test_tomography_comparison_helpers.py → pybinny-2.0.0/tests/test_analysis_comparison_helpers.py +2 -2
- pybinny-1.2.0/tests/test_tomography_comparison_similarity.py → pybinny-2.0.0/tests/test_analysis_comparison_similarity.py +1 -1
- pybinny-1.2.0/tests/test_tomography_composition.py → pybinny-2.0.0/tests/test_analysis_composition.py +1 -1
- pybinny-1.2.0/tests/test_tomography_stats.py → pybinny-2.0.0/tests/test_analysis_stats.py +32 -29
- pybinny-1.2.0/tests/test_tomography_stats_center_invariance_fast.py → pybinny-2.0.0/tests/test_analysis_stats_center_invariance_fast.py +2 -2
- pybinny-1.2.0/tests/test_tomography_stats_center_invariance_slow.py → pybinny-2.0.0/tests/test_analysis_stats_center_invariance_slow.py +2 -2
- pybinny-1.2.0/tests/test_tomography_stats_invariances.py → pybinny-2.0.0/tests/test_analysis_stats_invariances.py +14 -14
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_axes_mixed_edges_invariances_slow.py +1 -1
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_core.py +2 -2
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_edges.py +2 -2
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_kernels.py +149 -150
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_photoz_builder.py +192 -154
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_specz.py +136 -21
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_specz_builder.py +181 -185
- pybinny-1.2.0/tests/test_nz_calibration.py → pybinny-2.0.0/tests/test_calibration_depth.py +2 -2
- pybinny-2.0.0/tests/test_calibration_photoz_fitting.py +1050 -0
- pybinny-1.2.0/tests/test_nz_psf_selection.py → pybinny-2.0.0/tests/test_calibration_psf_selection.py +1 -1
- pybinny-2.0.0/tests/test_functional_binning_consistency.py +589 -0
- pybinny-2.0.0/tests/test_nz_sampling.py +588 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_predefined_api_consistency.py +2 -2
- pybinny-2.0.0/tests/test_public_api.py +190 -0
- pybinny-1.2.0/tests/test_utils_colors.py → pybinny-2.0.0/tests/test_style_colors.py +33 -33
- pybinny-2.0.0/tests/test_surveys_config_utils.py +428 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_surveys_survey_presets.py +4 -1
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_surveys_tomography.py +25 -1
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_tomography_builder.py +93 -11
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_tomography_core.py +144 -35
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_tomography_metadata_normalization.py +10 -9
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_tomography_predefined.py +94 -13
- pybinny-1.2.0/tests/test_surveys_config_utils.py → pybinny-2.0.0/tests/test_tomography_specs.py +51 -438
- pybinny-2.0.0/tests/test_utils_metadata_arrays.py +61 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_utils_normalization.py +151 -0
- pybinny-2.0.0/tests/test_utils_pairwise_metrics.py +127 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_utils_validators.py +44 -0
- pybinny-1.2.0/src/binny/__init__.py +0 -45
- pybinny-1.2.0/src/binny/binning/core.py +0 -160
- pybinny-1.2.0/src/binny/binning/specz.py +0 -611
- pybinny-1.2.0/src/binny/tomography/__init__.py +0 -82
- pybinny-1.2.0/src/binny/tomography/core.py +0 -171
- pybinny-1.2.0/src/binny/tomography/metadata.py +0 -71
- pybinny-1.2.0/tests/test_binning_photoz_fitting.py +0 -449
- pybinny-1.2.0/tests/test_functional_binning_consistency.py +0 -109
- pybinny-1.2.0/tests/test_utils_pairwise_metrics.py +0 -300
- {pybinny-1.2.0 → pybinny-2.0.0}/LICENSE +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/README.md +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/setup.cfg +0 -0
- {pybinny-1.2.0/src/binny/tomography → pybinny-2.0.0/src/binny/analysis}/composition.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/axes/__init__.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/axes/bin_edges.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/axes/grids.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/axes/mixed_edges.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/binning/assignments.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/binning/scheme_registry.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/binning/specs.py +0 -0
- pybinny-1.2.0/src/binny/nz/calibration.py → pybinny-2.0.0/src/binny/calibration/depth.py +0 -0
- {pybinny-1.2.0/src/binny/nz → pybinny-2.0.0/src/binny/calibration}/psf_selection.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/correlations/__init__.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/correlations/bin_combo_filter.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/correlations/filters.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/correlations/metrics.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/correlations/scores.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/correlations/topology.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/cosmology/__init__.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/cosmology/ccl_wrappers.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/nz/registry.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/__init__.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/__init__.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/des_survey_specs.yaml +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/desi_survey_specs.yaml +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/example_full_photoz.yaml +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/example_generalized_photoz.yaml +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/example_minimal_photoz.yaml +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/example_minimal_specz.yaml +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/example_tabulated.yaml +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/lsst_survey_specs.yaml +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/mock_predefined_config.yaml +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/roman_survey_specs.yaml +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/__init__.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/desi_bgs_sgc_nz.txt +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/desi_elg_nz.txt +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/desi_lrg_nz.txt +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/desi_lrg_sgc_nz.txt +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/example_tabulated_nz.txt +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/lsst_dp2_nz_degraded_r24p5_masked.txt +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/mock_predefined_bins.txt +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/roman_n_eff20.nz +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/roman_n_eff30.nz +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/roman_n_eff40.nz +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/roman_n_eff50.nz +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/scripts/fit_roman_smail.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/sky.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/__init__.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/broadcasting.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/relations.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/pybinny.egg-info/dependency_links.txt +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/src/pybinny.egg-info/requires.txt +1 -1
- {pybinny-1.2.0 → pybinny-2.0.0}/src/pybinny.egg-info/top_level.txt +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_axes_bin_edges.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_axes_grids.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_axes_mixed_edges.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_axes_mixed_edges_invariances_fast.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_photoz.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_scheme_registry.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_correlations_bin_combo_filter.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_correlations_filters.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_correlations_metrics.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_correlations_scores.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_correlations_topology.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_nz_luminosity_function_distribution.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_nz_models.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_nz_registry.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_surveys_sky.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_utils_broadcasting.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_utils_io.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_utils_metadata.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_utils_metadata_extended.py +0 -0
- {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_utils_relations.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pybinny
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: Flexible tomographic binning algorithms for cosmology.
|
|
5
5
|
Author-email: Nikolina Sarcevic <nikolina.sarcevic@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -10,7 +10,6 @@ License-File: LICENSE
|
|
|
10
10
|
Requires-Dist: numpy
|
|
11
11
|
Requires-Dist: pyyaml
|
|
12
12
|
Requires-Dist: scipy
|
|
13
|
-
Requires-Dist: cmasher
|
|
14
13
|
Requires-Dist: matplotlib
|
|
15
14
|
Requires-Dist: derivkit
|
|
16
15
|
Provides-Extra: lf
|
|
@@ -29,6 +28,7 @@ Requires-Dist: tox>=4.22; extra == "dev"
|
|
|
29
28
|
Requires-Dist: py-lfkit>=0.1.4; extra == "dev"
|
|
30
29
|
Requires-Dist: pyccl>=3; extra == "dev"
|
|
31
30
|
Provides-Extra: docs
|
|
31
|
+
Requires-Dist: cmasher; extra == "docs"
|
|
32
32
|
Requires-Dist: sphinx[doctest]<9; extra == "docs"
|
|
33
33
|
Requires-Dist: sphinx-copybutton; extra == "docs"
|
|
34
34
|
Requires-Dist: sphinx-design; extra == "docs"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pybinny"
|
|
3
|
-
version = "
|
|
3
|
+
version = "2.0.0"
|
|
4
4
|
description = "Flexible tomographic binning algorithms for cosmology."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
@@ -11,7 +11,6 @@ dependencies = [
|
|
|
11
11
|
"numpy",
|
|
12
12
|
"pyyaml",
|
|
13
13
|
"scipy",
|
|
14
|
-
"cmasher",
|
|
15
14
|
"matplotlib",
|
|
16
15
|
"derivkit",
|
|
17
16
|
]
|
|
@@ -37,6 +36,7 @@ dev = [
|
|
|
37
36
|
"pyccl>=3",
|
|
38
37
|
]
|
|
39
38
|
docs = [
|
|
39
|
+
"cmasher",
|
|
40
40
|
"sphinx[doctest]<9",
|
|
41
41
|
"sphinx-copybutton",
|
|
42
42
|
"sphinx-design",
|
|
@@ -102,7 +102,7 @@ where = ["src"]
|
|
|
102
102
|
]
|
|
103
103
|
|
|
104
104
|
[tool.bumpversion]
|
|
105
|
-
current_version = "
|
|
105
|
+
current_version = "2.0.0"
|
|
106
106
|
commit = true
|
|
107
107
|
tag = true
|
|
108
108
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Public Binny API."""
|
|
2
|
+
|
|
3
|
+
from binny import (
|
|
4
|
+
analysis,
|
|
5
|
+
binning,
|
|
6
|
+
calibration,
|
|
7
|
+
nz,
|
|
8
|
+
style,
|
|
9
|
+
surveys,
|
|
10
|
+
tomography,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"analysis",
|
|
15
|
+
"binning",
|
|
16
|
+
"calibration",
|
|
17
|
+
"nz",
|
|
18
|
+
"style",
|
|
19
|
+
"surveys",
|
|
20
|
+
"tomography",
|
|
21
|
+
]
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""Scientific analysis, comparison, composition, and correlation filtering."""
|
|
2
|
+
|
|
3
|
+
from binny.analysis.combinations import make_bin_combo_filter
|
|
4
|
+
from binny.analysis.comparison import (
|
|
5
|
+
between_bin_overlap,
|
|
6
|
+
between_interval_mass_matrix,
|
|
7
|
+
between_overlap_pairs,
|
|
8
|
+
between_pearson_matrix,
|
|
9
|
+
bin_overlap,
|
|
10
|
+
leakage_matrix,
|
|
11
|
+
overlap_pairs,
|
|
12
|
+
pearson_matrix,
|
|
13
|
+
)
|
|
14
|
+
from binny.analysis.composition import (
|
|
15
|
+
align_bin_grids,
|
|
16
|
+
combine_parent_nz,
|
|
17
|
+
combine_tomographies,
|
|
18
|
+
interpolate_tomography,
|
|
19
|
+
sample_bin_labels,
|
|
20
|
+
sample_bins,
|
|
21
|
+
sample_combinations,
|
|
22
|
+
)
|
|
23
|
+
from binny.analysis.stats import (
|
|
24
|
+
bin_centers,
|
|
25
|
+
bin_moments,
|
|
26
|
+
bin_quantiles,
|
|
27
|
+
comoving_density_per_bin,
|
|
28
|
+
galaxy_count_per_bin,
|
|
29
|
+
galaxy_density_per_bin,
|
|
30
|
+
galaxy_fraction_per_bin,
|
|
31
|
+
in_range_fraction,
|
|
32
|
+
in_range_fraction_per_bin,
|
|
33
|
+
parent_stats,
|
|
34
|
+
peak_flags,
|
|
35
|
+
peak_flags_per_bin,
|
|
36
|
+
population_stats,
|
|
37
|
+
shape_stats,
|
|
38
|
+
)
|
|
39
|
+
from binny.correlations import (
|
|
40
|
+
BinComboFilter,
|
|
41
|
+
filter_by_curve_norm_threshold,
|
|
42
|
+
filter_by_metric_threshold,
|
|
43
|
+
filter_by_score_consistency,
|
|
44
|
+
filter_by_score_difference,
|
|
45
|
+
filter_by_score_relation,
|
|
46
|
+
filter_by_score_separation,
|
|
47
|
+
filter_by_width_ratio,
|
|
48
|
+
metric_from_curves,
|
|
49
|
+
metric_min_overlap_fraction,
|
|
50
|
+
metric_overlap_coefficient,
|
|
51
|
+
pairs_all,
|
|
52
|
+
pairs_cartesian,
|
|
53
|
+
pairs_diagonal,
|
|
54
|
+
pairs_lower_triangle,
|
|
55
|
+
pairs_off_diagonal,
|
|
56
|
+
pairs_upper_triangle,
|
|
57
|
+
score_credible_width,
|
|
58
|
+
score_mean_location,
|
|
59
|
+
score_median_location,
|
|
60
|
+
score_peak_location,
|
|
61
|
+
tuples_all,
|
|
62
|
+
tuples_cartesian,
|
|
63
|
+
tuples_diagonal,
|
|
64
|
+
tuples_nondecreasing,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
__all__ = [
|
|
68
|
+
"BinComboFilter",
|
|
69
|
+
"align_bin_grids",
|
|
70
|
+
"between_bin_overlap",
|
|
71
|
+
"between_interval_mass_matrix",
|
|
72
|
+
"between_overlap_pairs",
|
|
73
|
+
"between_pearson_matrix",
|
|
74
|
+
"bin_centers",
|
|
75
|
+
"bin_moments",
|
|
76
|
+
"bin_overlap",
|
|
77
|
+
"bin_quantiles",
|
|
78
|
+
"combine_parent_nz",
|
|
79
|
+
"combine_tomographies",
|
|
80
|
+
"comoving_density_per_bin",
|
|
81
|
+
"filter_by_curve_norm_threshold",
|
|
82
|
+
"filter_by_metric_threshold",
|
|
83
|
+
"filter_by_score_consistency",
|
|
84
|
+
"filter_by_score_difference",
|
|
85
|
+
"filter_by_score_relation",
|
|
86
|
+
"filter_by_score_separation",
|
|
87
|
+
"filter_by_width_ratio",
|
|
88
|
+
"galaxy_count_per_bin",
|
|
89
|
+
"galaxy_density_per_bin",
|
|
90
|
+
"galaxy_fraction_per_bin",
|
|
91
|
+
"in_range_fraction",
|
|
92
|
+
"in_range_fraction_per_bin",
|
|
93
|
+
"interpolate_tomography",
|
|
94
|
+
"leakage_matrix",
|
|
95
|
+
"make_bin_combo_filter",
|
|
96
|
+
"metric_from_curves",
|
|
97
|
+
"metric_min_overlap_fraction",
|
|
98
|
+
"metric_overlap_coefficient",
|
|
99
|
+
"overlap_pairs",
|
|
100
|
+
"pairs_all",
|
|
101
|
+
"pairs_cartesian",
|
|
102
|
+
"pairs_diagonal",
|
|
103
|
+
"pairs_lower_triangle",
|
|
104
|
+
"pairs_off_diagonal",
|
|
105
|
+
"pairs_upper_triangle",
|
|
106
|
+
"parent_stats",
|
|
107
|
+
"peak_flags",
|
|
108
|
+
"peak_flags_per_bin",
|
|
109
|
+
"pearson_matrix",
|
|
110
|
+
"population_stats",
|
|
111
|
+
"sample_bin_labels",
|
|
112
|
+
"sample_bins",
|
|
113
|
+
"sample_combinations",
|
|
114
|
+
"score_credible_width",
|
|
115
|
+
"score_mean_location",
|
|
116
|
+
"score_median_location",
|
|
117
|
+
"score_peak_location",
|
|
118
|
+
"shape_stats",
|
|
119
|
+
"tuples_all",
|
|
120
|
+
"tuples_cartesian",
|
|
121
|
+
"tuples_diagonal",
|
|
122
|
+
"tuples_nondecreasing",
|
|
123
|
+
]
|
|
@@ -7,7 +7,7 @@ from typing import Any, Literal
|
|
|
7
7
|
|
|
8
8
|
import numpy as np
|
|
9
9
|
|
|
10
|
-
from binny.
|
|
10
|
+
from binny.analysis.composition import align_bin_grids
|
|
11
11
|
from binny.utils.metadata import round_floats
|
|
12
12
|
from binny.utils.normalization import (
|
|
13
13
|
normalize_edges,
|
|
@@ -413,18 +413,22 @@ def peak_flags_per_bin(
|
|
|
413
413
|
|
|
414
414
|
def galaxy_fraction_per_bin(meta: Mapping[str, Any]) -> dict[int, float]:
|
|
415
415
|
"""Extract and normalize per-bin population fractions from tomo metadata."""
|
|
416
|
-
|
|
416
|
+
bins_meta = meta.get("bins")
|
|
417
417
|
|
|
418
|
-
if
|
|
419
|
-
|
|
418
|
+
if not isinstance(bins_meta, Mapping):
|
|
419
|
+
raise ValueError("metadata must contain a mapping 'bins'.")
|
|
420
420
|
|
|
421
|
-
|
|
422
|
-
|
|
421
|
+
frac = bins_meta.get("frac_per_bin")
|
|
422
|
+
|
|
423
|
+
if not isinstance(frac, Mapping):
|
|
424
|
+
raise ValueError("metadata must contain a mapping 'bins.frac_per_bin'.")
|
|
423
425
|
|
|
424
426
|
out: dict[int, float] = {int(k): float(v) for k, v in frac.items()}
|
|
425
427
|
s = float(sum(out.values()))
|
|
428
|
+
|
|
426
429
|
if s <= 0.0:
|
|
427
430
|
raise ValueError("Sum of metadata frac_per_bin must be positive.")
|
|
431
|
+
|
|
428
432
|
return {i: f / s for i, f in out.items()}
|
|
429
433
|
|
|
430
434
|
|
|
@@ -470,7 +474,7 @@ def galaxy_density_per_bin(
|
|
|
470
474
|
effective density..
|
|
471
475
|
|
|
472
476
|
Args:
|
|
473
|
-
metadata: Tomography metadata containing ``"frac_per_bin"``.
|
|
477
|
+
metadata: Tomography metadata containing ``metadata["bins"]["frac_per_bin"]``.
|
|
474
478
|
density_total: Total effective surface density (gal/arcmin^2).
|
|
475
479
|
|
|
476
480
|
Returns:
|
|
@@ -630,7 +634,7 @@ def population_stats(
|
|
|
630
634
|
This function computes quantities that depend on relative bin populations,
|
|
631
635
|
using metadata produced by Binny's tomo builders.
|
|
632
636
|
|
|
633
|
-
The primary input is ``metadata["frac_per_bin"]`` (mapping bin index to
|
|
637
|
+
The primary input is ``metadata["bins"]["frac_per_bin"]`` (mapping bin index to
|
|
634
638
|
fraction). Fractions are checked against the bin indices present in
|
|
635
639
|
``bins``.
|
|
636
640
|
|
|
@@ -645,7 +649,7 @@ def population_stats(
|
|
|
645
649
|
|
|
646
650
|
Args:
|
|
647
651
|
bins: Mapping from bin index to bin curves.
|
|
648
|
-
metadata: Tomography metadata containing ``"frac_per_bin"``.
|
|
652
|
+
metadata: Tomography metadata containing ``metadata["bins"]["frac_per_bin"]``.
|
|
649
653
|
density_total: Optional total effective surface density in
|
|
650
654
|
galaxies per square arcminute.
|
|
651
655
|
survey_area: Optional survey area in square arcminutes. Requires
|
|
@@ -670,7 +674,7 @@ def population_stats(
|
|
|
670
674
|
|
|
671
675
|
Raises:
|
|
672
676
|
ValueError: If bins is empty.
|
|
673
|
-
ValueError: If metadata does not contain
|
|
677
|
+
ValueError: If metadata does not contain valid per-bin population fractions.
|
|
674
678
|
ValueError: If metadata fractions are missing any bin index.
|
|
675
679
|
ValueError: If ``survey_area`` is provided without ``density_total``.
|
|
676
680
|
ValueError: If only one of ``total_count_per_bin`` and
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Bin-edge construction, binning schemes, and assignment models."""
|
|
2
2
|
|
|
3
|
+
from binny.axes import (
|
|
4
|
+
chebyshev_edges,
|
|
5
|
+
equal_information_edges,
|
|
6
|
+
equal_number_edges,
|
|
7
|
+
equidistant_chi_edges,
|
|
8
|
+
equidistant_edges,
|
|
9
|
+
generalized_tomographic_edges,
|
|
10
|
+
geometric_edges,
|
|
11
|
+
log_edges,
|
|
12
|
+
mixed_edges,
|
|
13
|
+
power_edges,
|
|
14
|
+
sinh_edges,
|
|
15
|
+
)
|
|
3
16
|
from binny.binning.assignments import (
|
|
4
17
|
deterministic_assignment,
|
|
5
18
|
specz_selection_in_bin,
|
|
@@ -12,15 +25,10 @@ from binny.binning.edges import (
|
|
|
12
25
|
validate_bin_edges,
|
|
13
26
|
)
|
|
14
27
|
from binny.binning.photoz import (
|
|
15
|
-
build_photoz_bins,
|
|
16
28
|
photoz_assignment,
|
|
17
29
|
photoz_assignment_probability,
|
|
18
30
|
true_redshift_distribution,
|
|
19
31
|
)
|
|
20
|
-
from binny.binning.photoz_fitting import (
|
|
21
|
-
fit_photoz_errors,
|
|
22
|
-
to_binny_photoz_params,
|
|
23
|
-
)
|
|
24
32
|
from binny.binning.scheme_registry import (
|
|
25
33
|
available_binning_schemes,
|
|
26
34
|
get_binning_scheme,
|
|
@@ -28,32 +36,40 @@ from binny.binning.scheme_registry import (
|
|
|
28
36
|
)
|
|
29
37
|
from binny.binning.specz import (
|
|
30
38
|
apply_response_matrix,
|
|
31
|
-
build_specz_bins,
|
|
32
39
|
build_specz_response_matrix,
|
|
33
40
|
specz_assignment,
|
|
34
41
|
specz_gaussian_response_matrix,
|
|
35
42
|
)
|
|
43
|
+
from binny.utils.io import load_binning_recipe
|
|
36
44
|
|
|
37
45
|
__all__ = [
|
|
38
46
|
"apply_response_matrix",
|
|
39
47
|
"available_binning_schemes",
|
|
40
48
|
"build_bins",
|
|
41
|
-
"build_photoz_bins",
|
|
42
|
-
"build_specz_bins",
|
|
43
49
|
"build_specz_response_matrix",
|
|
50
|
+
"chebyshev_edges",
|
|
44
51
|
"deterministic_assignment",
|
|
45
|
-
"
|
|
52
|
+
"equal_information_edges",
|
|
53
|
+
"equal_number_edges",
|
|
54
|
+
"equidistant_chi_edges",
|
|
55
|
+
"equidistant_edges",
|
|
56
|
+
"generalized_tomographic_edges",
|
|
57
|
+
"geometric_edges",
|
|
46
58
|
"get_binning_scheme",
|
|
59
|
+
"load_binning_recipe",
|
|
60
|
+
"log_edges",
|
|
61
|
+
"mixed_edges",
|
|
47
62
|
"mixed_edges_from_segments",
|
|
48
63
|
"photoz_assignment",
|
|
49
64
|
"photoz_assignment_probability",
|
|
65
|
+
"power_edges",
|
|
50
66
|
"register_binning_scheme",
|
|
51
67
|
"resolve_bin_edges",
|
|
52
68
|
"segments_to_axes",
|
|
69
|
+
"sinh_edges",
|
|
53
70
|
"specz_assignment",
|
|
54
71
|
"specz_gaussian_response_matrix",
|
|
55
72
|
"specz_selection_in_bin",
|
|
56
|
-
"to_binny_photoz_params",
|
|
57
73
|
"true_redshift_distribution",
|
|
58
74
|
"validate_bin_edges",
|
|
59
75
|
]
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""Generic selection-based tomographic binning."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Callable
|
|
6
|
+
from typing import Literal
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
|
|
10
|
+
from binny.binning.edges import validate_bin_edges
|
|
11
|
+
from binny.utils.normalization import integrate_1d
|
|
12
|
+
from binny.utils.types import FloatArray
|
|
13
|
+
from binny.utils.validators import validate_axis_and_weights
|
|
14
|
+
|
|
15
|
+
__all__ = ["build_bins"]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def build_bins(
|
|
19
|
+
z: FloatArray,
|
|
20
|
+
nz: FloatArray,
|
|
21
|
+
edges: FloatArray,
|
|
22
|
+
assignment: Callable[[FloatArray, FloatArray], FloatArray],
|
|
23
|
+
*,
|
|
24
|
+
selection_kind: Literal["probability", "weight"] = "probability",
|
|
25
|
+
normalize_bins: bool = False,
|
|
26
|
+
norm_method: Literal["trapezoid", "simpson"] = "trapezoid",
|
|
27
|
+
return_integrals: bool = False,
|
|
28
|
+
) -> dict[int, FloatArray] | tuple[dict[int, FloatArray], dict[int, float], float]:
|
|
29
|
+
"""Build tomographic bins using a selection function.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
z: Parent redshift grid.
|
|
33
|
+
nz: Parent redshift distribution.
|
|
34
|
+
edges: Bin edges in the selection coordinate.
|
|
35
|
+
assignment: Function returning selections of shape
|
|
36
|
+
``(n_bins, n_z)``.
|
|
37
|
+
selection_kind: Whether selections are probabilities in
|
|
38
|
+
``[0, 1]`` or non-negative weights.
|
|
39
|
+
normalize_bins: Whether to normalize each bin.
|
|
40
|
+
norm_method: Integration method for normalization and population integrals.
|
|
41
|
+
return_integrals: Whether to return raw bin integrals
|
|
42
|
+
and the parent integral.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
Dictionary of bin distributions, optionally accompanied
|
|
46
|
+
by bin integrals and the parent integral.
|
|
47
|
+
|
|
48
|
+
Raises:
|
|
49
|
+
ValueError: If the selection type, shape, or values are invalid.
|
|
50
|
+
"""
|
|
51
|
+
z_arr, nz_arr = validate_axis_and_weights(z, nz)
|
|
52
|
+
edges_arr = validate_bin_edges(edges)
|
|
53
|
+
|
|
54
|
+
if selection_kind not in {"probability", "weight"}:
|
|
55
|
+
raise ValueError("selection_kind must be 'probability' or 'weight'.")
|
|
56
|
+
|
|
57
|
+
selection = np.asarray(assignment(z_arr, edges_arr), dtype=np.float64)
|
|
58
|
+
expected_shape = (edges_arr.size - 1, z_arr.size)
|
|
59
|
+
|
|
60
|
+
if selection.shape != expected_shape:
|
|
61
|
+
raise ValueError(f"assignment returned shape {selection.shape}, expected {expected_shape}.")
|
|
62
|
+
|
|
63
|
+
if not np.all(np.isfinite(selection)):
|
|
64
|
+
raise ValueError("Selection values must be finite.")
|
|
65
|
+
|
|
66
|
+
if np.any(selection < 0.0):
|
|
67
|
+
raise ValueError("Selection values must be non-negative.")
|
|
68
|
+
|
|
69
|
+
if selection_kind == "probability" and np.any(selection > 1.0):
|
|
70
|
+
raise ValueError("Selection probabilities must not exceed 1.")
|
|
71
|
+
|
|
72
|
+
bins: dict[int, FloatArray] = {}
|
|
73
|
+
bin_integrals: dict[int, float] = {}
|
|
74
|
+
|
|
75
|
+
for i, probability in enumerate(selection):
|
|
76
|
+
raw = nz_arr * probability
|
|
77
|
+
area = integrate_1d(z_arr, raw, method=norm_method)
|
|
78
|
+
|
|
79
|
+
if return_integrals:
|
|
80
|
+
bin_integrals[i] = area
|
|
81
|
+
|
|
82
|
+
if normalize_bins and area > 0.0:
|
|
83
|
+
raw = raw / area
|
|
84
|
+
|
|
85
|
+
bins[i] = raw
|
|
86
|
+
|
|
87
|
+
if return_integrals:
|
|
88
|
+
parent_integral = integrate_1d(z_arr, nz_arr, method=norm_method)
|
|
89
|
+
return bins, bin_integrals, parent_integral
|
|
90
|
+
|
|
91
|
+
return bins
|
|
@@ -36,7 +36,6 @@ __all__ = [
|
|
|
36
36
|
"resolve_bin_edges",
|
|
37
37
|
"validate_bin_edges",
|
|
38
38
|
"segments_to_axes",
|
|
39
|
-
"photoz_segments_to_axes",
|
|
40
39
|
"mixed_edges_from_segments",
|
|
41
40
|
]
|
|
42
41
|
|
|
@@ -510,27 +509,6 @@ def segments_to_axes(
|
|
|
510
509
|
return result
|
|
511
510
|
|
|
512
511
|
|
|
513
|
-
def photoz_segments_to_axes(
|
|
514
|
-
segments: Sequence[Mapping[str, Any]],
|
|
515
|
-
) -> list[dict[str, Any]]:
|
|
516
|
-
"""Convert legacy photo-z segments to generic axis descriptions.
|
|
517
|
-
|
|
518
|
-
This compatibility function accepts the same segment specifications
|
|
519
|
-
as :func:`segments_to_axes`. New code should call that function
|
|
520
|
-
directly.
|
|
521
|
-
|
|
522
|
-
Args:
|
|
523
|
-
segments: Ordered segment specifications.
|
|
524
|
-
|
|
525
|
-
Returns:
|
|
526
|
-
List of generic axis-level segment descriptions.
|
|
527
|
-
|
|
528
|
-
Raises:
|
|
529
|
-
ValueError: If a segment specification is invalid.
|
|
530
|
-
"""
|
|
531
|
-
return segments_to_axes(segments)
|
|
532
|
-
|
|
533
|
-
|
|
534
512
|
def mixed_edges_from_segments(
|
|
535
513
|
segments: Sequence[Mapping[str, Any]],
|
|
536
514
|
*,
|