Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f067b3e
replace files with crow
m-aguena Nov 5, 2025
64c9622
working cosmosis with cluster_redshift_richness_deltasigma.py
eduardojsbarroso Nov 5, 2025
b5c126c
Merge branch 'master' into issues/580/crow
vitenti Nov 11, 2025
cd91962
Merge branch 'master' into issues/580/crow
eduardojsbarroso Dec 1, 2025
ecd8417
Fixing imports, working example of cluster_redshift_richness_deltasig…
eduardojsbarroso Dec 1, 2025
397e534
Setup before calling recipe
eduardojsbarroso Dec 1, 2025
9a36cf6
Implemented reduced shear data reading and examples
eduardojsbarroso Dec 2, 2025
9f75c49
Working examples for all cases
eduardojsbarroso Dec 2, 2025
35d0c29
Fixed reduced shear examples and black and pylint
eduardojsbarroso Dec 2, 2025
b7b7319
Fix tests, mypy and pylint
eduardojsbarroso Dec 3, 2025
3727791
Adding crow as dependency
eduardojsbarroso Dec 3, 2025
9612e49
Trigger CI
eduardojsbarroso Dec 3, 2025
46c6eaa
Changed environment
eduardojsbarroso Dec 3, 2025
b084d40
Trigger CI
eduardojsbarroso Dec 3, 2025
f52db4b
Fixed parameter naming to for numcosmo run
eduardojsbarroso Dec 4, 2025
be02b68
Fixed parameter name in test
eduardojsbarroso Dec 4, 2025
28ea716
Changed objects to handle only shear or only deltasigma
eduardojsbarroso Dec 4, 2025
fab70cf
Merge branch 'master' into issues/580/crow
marcpaterno Dec 10, 2025
302c28b
Removed wrong import from test
eduardojsbarroso Dec 11, 2025
3fdd101
Removed old tests
eduardojsbarroso Dec 11, 2025
20a6275
Merge branch 'master' into issues/580/crow
vitenti Dec 11, 2025
e09acf5
Merge branch 'master' into issues/580/crow
marcpaterno Jan 13, 2026
0723aef
Fixed flake8 problems
eduardojsbarroso Jan 19, 2026
b1ddbaf
Black
eduardojsbarroso Jan 19, 2026
13fce6c
Fix bug with black and flake8
eduardojsbarroso Jan 19, 2026
5b27310
Typo
eduardojsbarroso Jan 19, 2026
01ef4a2
Fixed cyclic imports
eduardojsbarroso Jan 19, 2026
4dffb4d
Fixed reset aprameters for very iteration
eduardojsbarroso Feb 2, 2026
f0b23eb
Properly reset grid
eduardojsbarroso Feb 10, 2026
566c6ac
Changed reset line
eduardojsbarroso Feb 13, 2026
4f315d4
Added prior to prediction
eduardojsbarroso Apr 2, 2026
3adc09e
Fix typo
eduardojsbarroso Apr 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies:
- pip >= 20.1 # pip is needed as dependency
- pip:
- cobaya
- desc-crow
- isitgr
- pygobject-stubs
- plotnine < 0.15
Expand Down
61 changes: 50 additions & 11 deletions examples/cluster_number_counts/cluster_SDSS_redshift_richness.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,65 @@

import pyccl as ccl


from crow import ClusterAbundance, kernel, mass_proxy
from crow.properties import ClusterProperty
from crow.recipes.binned_exact import ExactBinnedClusterRecipe

from firecrown.likelihood.factories import load_sacc_data
from firecrown.likelihood import (
BinnedClusterNumberCounts,
ConstGaussian,
Likelihood,
NamedParameters,
)

from firecrown.modeling_tools import ModelingTools
from firecrown.models.cluster import ClusterAbundance, ClusterProperty
from firecrown.models.cluster import MurataBinnedSpecZRecipe


def get_cluster_abundance() -> ClusterAbundance:
"""Creates and returns a ClusterAbundance object."""
hmf = ccl.halos.MassFuncBocquet16()
min_mass, max_mass = 13.0, 17.0
min_z, max_z = 0.2, 0.8
cluster_abundance = ClusterAbundance((min_mass, max_mass), (min_z, max_z), hmf)
"""Creates and returns a ClusterShearProfile object."""
cluster_theory = ClusterAbundance(
cosmo=ccl.CosmologyVanillaLCDM(),
halo_mass_function=ccl.halos.MassFuncTinker08(mass_def="200c"),
)

return cluster_theory


def get_cluster_recipe(
cluster_theory=None,
pivot_mass: float = 14.625862906,
pivot_redshift: float = 0.6,
mass_interval=(12, 17),
true_z_interval=(0.1, 2.0),
):
"""Creates and returns an ExactBinnedClusterRecipe.

Parameters
----------
cluster_theory : ClusterShearProfile or None
If None, uses get_cluster_shear_profile()
Returns
-------
ExactBinnedClusterRecipe
"""
if cluster_theory is None:
cluster_theory = get_cluster_abundance()
redshift_distribution = kernel.SpectroscopicRedshift()
mass_distribution = mass_proxy.MurataBinned(pivot_mass, pivot_redshift)

recipe = ExactBinnedClusterRecipe(
cluster_theory=cluster_theory,
redshift_distribution=redshift_distribution,
mass_distribution=mass_distribution,
completeness=None,
purity=None,
mass_interval=mass_interval,
true_z_interval=true_z_interval,
)

return cluster_abundance
return recipe


def build_likelihood(
Expand All @@ -38,8 +77,9 @@ def build_likelihood(
average_on |= ClusterProperty.MASS

survey_name = "SDSSCluster_redshift_richness"
recipe = get_cluster_recipe()
likelihood = ConstGaussian(
[BinnedClusterNumberCounts(average_on, survey_name, MurataBinnedSpecZRecipe())]
[BinnedClusterNumberCounts(average_on, survey_name, recipe)]
)

# Read in sacc data
Expand All @@ -50,7 +90,6 @@ def build_likelihood(
sacc_data = load_sacc_data(os.path.join(sacc_path, sacc_file_nm))
likelihood.read(sacc_data)

cluster_abundance = get_cluster_abundance()
modeling_tools = ModelingTools(cluster_abundance=cluster_abundance)
modeling_tools = ModelingTools()

return likelihood, modeling_tools
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
[runtime]
sampler = test
resume = T
root = ${PWD}

[default]
fatal_errors = T

[output]
filename = output_rps_2/number_counts_samples.txt
format = text
verbosity = 0

[pipeline]
modules = consistency camb firecrown_likelihood
values = ${FIRECROWN_DIR}/examples/cluster_number_counts/cluster_richness_values_deltasigma.ini
likelihoods = firecrown
quiet = T
debug = T
timing = T

[consistency]
file = ${CSL_DIR}/utility/consistency/consistency_interface.py

[camb]
file = ${CSL_DIR}/boltzmann/camb/camb_interface.py

mode = all
lmax = 2500
feedback = 0
zmin = 0.0
zmax = 1.0
nz = 100
kmin = 1e-4
kmax = 50.0
nk = 1000

[firecrown_likelihood]
;; Fix this to use an environment variable to find the files.
;; Set FIRECROWN_DIR to the base of the firecrown installation (or build, if you haven't
;; installed it)
file = ${FIRECROWN_DIR}/firecrown/connector/cosmosis/likelihood.py
likelihood_source = ${FIRECROWN_DIR}/examples/cluster_number_counts/cluster_redshift_richness_deltasigma.py
sampling_parameters_sections = firecrown_number_counts
use_cluster_counts = True
use_mean_log_mass = False
use_mean_deltasigma = True
use_mean_reduced_shear = False

[test]
fatal_errors = T
save_dir = output_counts_mean_mass

[metropolis]
samples = 1000
nsteps = 1

[emcee]
walkers = 20
samples = 4000
nsteps = 3
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ nk = 1000
;; Set FIRECROWN_DIR to the base of the firecrown installation (or build, if you haven't
;; installed it)
file = ${FIRECROWN_DIR}/firecrown/connector/cosmosis/likelihood.py
likelihood_source = ${FIRECROWN_DIR}/examples/cluster_number_counts/cluster_redshift_richness_deltasigma.py
likelihood_source = ${FIRECROWN_DIR}/examples/cluster_number_counts/cluster_redshift_richness_reduced_shear.py
sampling_parameters_sections = firecrown_number_counts
use_cluster_counts = True
use_mean_log_mass = False
use_mean_deltasigma = True
use_mean_deltasigma = False
use_mean_reduced_shear = True

[test]
fatal_errors = T
Expand Down
61 changes: 50 additions & 11 deletions examples/cluster_number_counts/cluster_redshift_richness.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,65 @@

import pyccl as ccl

from crow import ClusterAbundance, kernel, mass_proxy
from crow.properties import ClusterProperty
from crow.recipes.binned_exact import ExactBinnedClusterRecipe

from firecrown.likelihood.factories import load_sacc_data
from firecrown.likelihood import (
BinnedClusterNumberCounts,
ConstGaussian,
Likelihood,
NamedParameters,
)

from firecrown.modeling_tools import ModelingTools
from firecrown.models.cluster import ClusterAbundance, ClusterProperty
from firecrown.models.cluster import MurataBinnedSpecZRecipe


def get_cluster_abundance() -> ClusterAbundance:
"""Creates and returns a ClusterAbundance object."""
hmf = ccl.halos.MassFuncBocquet16()
min_mass, max_mass = 13.0, 16.0
min_z, max_z = 0.2, 0.8
cluster_abundance = ClusterAbundance((min_mass, max_mass), (min_z, max_z), hmf)
"""Creates and returns a ClusterShearProfile."""
cluster_theory = ClusterAbundance(
cosmo=ccl.CosmologyVanillaLCDM(),
halo_mass_function=ccl.halos.MassFuncTinker08(mass_def="200c"),
)

return cluster_theory


def get_cluster_recipe(
cluster_theory=None,
pivot_mass: float = 14.625862906,
pivot_redshift: float = 0.6,
mass_interval=(12, 17),
true_z_interval=(0.1, 2.0),
):
"""Creates and returns an ExactBinnedClusterRecipe.

Parameters
----------
cluster_theory : ClusterShearProfile or None
If None, uses get_cluster_shear_profile()

Returns
-------
ExactBinnedClusterRecipe
"""
if cluster_theory is None:
cluster_theory = get_cluster_abundance()
redshift_distribution = kernel.SpectroscopicRedshift()
mass_distribution = mass_proxy.MurataBinned(pivot_mass, pivot_redshift)

recipe = ExactBinnedClusterRecipe(
cluster_theory=cluster_theory,
redshift_distribution=redshift_distribution,
mass_distribution=mass_distribution,
completeness=None,
purity=None,
mass_interval=mass_interval,
true_z_interval=true_z_interval,
)

return cluster_abundance
return recipe


def build_likelihood(
Expand All @@ -38,8 +77,9 @@ def build_likelihood(
average_on |= ClusterProperty.MASS

survey_name = "numcosmo_simulated_redshift_richness"
recipe = get_cluster_recipe()
likelihood = ConstGaussian(
[BinnedClusterNumberCounts(average_on, survey_name, MurataBinnedSpecZRecipe())]
[BinnedClusterNumberCounts(average_on, survey_name, recipe)]
)

# Read in sacc data
Expand All @@ -50,7 +90,6 @@ def build_likelihood(
sacc_data = load_sacc_data(os.path.join(sacc_path, sacc_file_nm))
likelihood.read(sacc_data)

cluster_abundance = get_cluster_abundance()
modeling_tools = ModelingTools(cluster_abundance=cluster_abundance)
modeling_tools = ModelingTools()

return likelihood, modeling_tools
Loading