-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue/438/cluster wl simple #461
Open
eduardojsbarroso
wants to merge
50
commits into
master
Choose a base branch
from
issue/438/cluster_wl_simple
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 17 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
b33bf4a
modify script to also generate mock shear profile sacc file
combet 4f242c1
add scripts to generate deltatheta sacc data
m-aguena 2c0dbed
Started to implement shear profile models and tests
eduardojsbarroso 4d154d9
Add one more test for DeltaSigma object
eduardojsbarroso 12b5413
add change
m-aguena b6f413f
fix conflict
m-aguena 6d4fc3c
add draft for shear
m-aguena 8ef9624
Added DeltaSigmaStatics for shear analysis and created examples
eduardojsbarroso e228fb0
Revert "add draft for shear"
eduardojsbarroso 10fd49b
Merge branch 'issue/438/cluster_wl_simple' of https://github.com/LSST…
eduardojsbarroso f5f8beb
Revert "add draft for shear"
eduardojsbarroso bcb7808
Implemented concentration as parameter or function call
eduardojsbarroso 3fcbb00
Merge branch 'master' into issue/438/cluster_wl_simple
eduardojsbarroso 703b179
Added comment to ini file to be used if needed
eduardojsbarroso 1372e3f
Added CosmoDC2 SACC file to examples
eduardojsbarroso 162fff2
Fix typo
eduardojsbarroso 833ba3a
Cleaned code and changed abstract method of cluste recipe
eduardojsbarroso 41a6a0e
Running black
eduardojsbarroso d69a23e
More cleaning on the code
eduardojsbarroso 51b9789
Runned black
eduardojsbarroso 7e62c53
Running flake8
eduardojsbarroso c25ca5e
Ignoring dulicate code and commented old test
eduardojsbarroso c792d1d
Disable unable to import
eduardojsbarroso 358c0b5
Refactored objects to avoid duplicated code
eduardojsbarroso 80b435b
Changed abstract method variable definition
eduardojsbarroso 46f91e0
Changed number of initiation variables for ClusterAbundance
eduardojsbarroso de49909
Fix function input
eduardojsbarroso db0edbc
Minor change
eduardojsbarroso 8f474bf
Merge branch 'master' into issue/438/cluster_wl_simple
eduardojsbarroso 9706a7c
Changed for new Data and Theory vectors
eduardojsbarroso d9736f8
Adding CLMM to requisites.
vitenti ea0de99
Merge branch 'master' into issue/438/cluster_wl_simple
vitenti 9824ff7
Minor fixes
eduardojsbarroso 49dcb86
Merge branch 'master' into issue/438/cluster_wl_simple
eduardojsbarroso ed705ec
Changed test
eduardojsbarroso 7fe5229
Added CLMM to docs/environment.yml
eduardojsbarroso 0977f6c
Improving tests
eduardojsbarroso 60be60e
More testing
eduardojsbarroso e67fbd0
Run black
eduardojsbarroso bc93dba
Removed unecessary condition
eduardojsbarroso e04795d
Fix data object
eduardojsbarroso b6d65f8
Running black
eduardojsbarroso 1ba148e
Black
eduardojsbarroso ad34b39
More testing
eduardojsbarroso 8ba36c7
Merge branch 'master' into issue/438/cluster_wl_simple
vitenti 55e5dd9
Merge branch 'master' into issue/438/cluster_wl_simple
eduardojsbarroso c9abc4b
Resolved datatype inconsistency in tests
eduardojsbarroso 31c12e1
Run black
eduardojsbarroso 625263b
Merge branch 'master' into issue/438/cluster_wl_simple
vitenti 7e6e77b
Merge branch 'master' into issue/438/cluster_wl_simple
vitenti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
examples/cluster_number_counts/cluster_counts_mean_mass_redshift_richness_shear.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
[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 = True | ||
use_mean_deltasigma = True | ||
|
||
[test] | ||
fatal_errors = T | ||
save_dir = output_counts_mean_mass | ||
|
||
[metropolis] | ||
samples = 1000 | ||
nsteps = 1 | ||
|
||
[emcee] | ||
walkers = 20 | ||
samples = 4000 | ||
nsteps = 3 |
87 changes: 87 additions & 0 deletions
87
examples/cluster_number_counts/cluster_redshift_richness_deltasigma.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
"""Likelihood factory function for cluster number counts.""" | ||
|
||
import os | ||
|
||
import pyccl as ccl | ||
import sacc | ||
|
||
from firecrown.likelihood.gaussian import ConstGaussian | ||
from firecrown.likelihood.binned_cluster_number_counts_deltasigma import ( | ||
BinnedClusterDeltaSigma, | ||
) | ||
from firecrown.likelihood.binned_cluster_number_counts import ( | ||
BinnedClusterNumberCounts, | ||
) | ||
|
||
from firecrown.likelihood.likelihood import Likelihood, NamedParameters | ||
from firecrown.modeling_tools import ModelingTools | ||
from firecrown.models.cluster.abundance import ClusterAbundance | ||
from firecrown.models.cluster.deltasigma import ClusterDeltaSigma | ||
from firecrown.models.cluster.properties import ClusterProperty | ||
from firecrown.models.cluster.recipes.murata_binned_spec_z_deltasigma import ( | ||
MurataBinnedSpecZDeltaSigmaRecipe, | ||
) | ||
from firecrown.models.cluster.recipes.murata_binned_spec_z import ( | ||
MurataBinnedSpecZRecipe, | ||
) | ||
|
||
|
||
def get_cluster_abundance() -> ClusterAbundance: | ||
"""Creates and returns a ClusterAbundance object.""" | ||
hmf = ccl.halos.MassFuncTinker08() | ||
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) | ||
|
||
return cluster_abundance | ||
|
||
|
||
def get_cluster_deltasigma() -> ClusterDeltaSigma: | ||
"""Creates and returns a ClusterAbundance object.""" | ||
hmf = ccl.halos.MassFuncTinker08() | ||
min_mass, max_mass = 13.0, 16.0 | ||
min_z, max_z = 0.2, 0.8 | ||
cluster_deltasigma = ClusterDeltaSigma(min_mass, max_mass, min_z, max_z, hmf) | ||
|
||
return cluster_deltasigma | ||
|
||
|
||
def build_likelihood( | ||
build_parameters: NamedParameters, | ||
) -> tuple[Likelihood, ModelingTools]: | ||
"""Builds the likelihood for Firecrown.""" | ||
# Pull params for the likelihood from build_parameters | ||
average_on = ClusterProperty.NONE | ||
if build_parameters.get_bool("use_cluster_counts", True): | ||
average_on |= ClusterProperty.COUNTS | ||
if build_parameters.get_bool("use_mean_log_mass", True): | ||
average_on |= ClusterProperty.MASS | ||
if build_parameters.get_bool("use_mean_deltasigma", True): | ||
average_on |= ClusterProperty.DELTASIGMA | ||
|
||
survey_name = "numcosmo_simulated_redshift_richness_deltasigma" | ||
likelihood = ConstGaussian( | ||
[ | ||
BinnedClusterNumberCounts( | ||
average_on, survey_name, MurataBinnedSpecZRecipe() | ||
), | ||
BinnedClusterDeltaSigma( | ||
average_on, survey_name, MurataBinnedSpecZDeltaSigmaRecipe() | ||
), | ||
] | ||
) | ||
|
||
# Read in sacc data | ||
sacc_file_nm = "cluster_redshift_richness_deltasigma_sacc_data.fits" | ||
sacc_path = os.path.expanduser( | ||
os.path.expandvars("${FIRECROWN_DIR}/examples/cluster_number_counts/") | ||
) | ||
sacc_data = sacc.Sacc.load_fits(os.path.join(sacc_path, sacc_file_nm)) | ||
likelihood.read(sacc_data) | ||
cluster_abundance = get_cluster_abundance() | ||
cluster_deltasigma = get_cluster_deltasigma() | ||
modeling_tools = ModelingTools( | ||
cluster_abundance=cluster_abundance, cluster_deltasigma=cluster_deltasigma | ||
) | ||
|
||
return likelihood, modeling_tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
examples/cluster_number_counts/cluster_richness_values_deltasigma.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
; Parameters and data in CosmoSIS are organized into sections | ||
; so we can easily see what they mean. | ||
; There is only one section in this case, called cosmological_parameters | ||
[cosmological_parameters] | ||
|
||
; These are the only cosmological parameters being varied. | ||
omega_c = 0.1552 0.22 0.3552 | ||
# We are choosing to use a flat prior in sigma_8. | ||
# To choose a float prior in A_s, remove the specification | ||
# of a prior for sigma_8 and replace it with the | ||
# desired range for A_s | ||
sigma_8 = 0.7 0.800 0.9 | ||
; The following parameters are set, but not varied. | ||
; | ||
omega_k = 0.0 | ||
omega_b = 0.0448 | ||
tau = 0.08 | ||
n_s = 0.963 | ||
h0 = 0.71 | ||
w = -1.0 | ||
wa = 0.0 | ||
|
||
[firecrown_number_counts] | ||
; These are the firecrown likelihood parameters. | ||
; These parameters are used to set the richness-mass | ||
; proxy relation using the data from cluster number counts. | ||
; | ||
; The following parameters can be fixed in the same way as the above | ||
; cosmological parameters if needed. | ||
mu_p0 = 3.19 | ||
mu_p1 = 0.8685889638 | ||
mu_p2 = -0.304 | ||
sigma_p0 = 0.33 | ||
sigma_p1 = -0.034 | ||
sigma_p2 = 0 | ||
#cluster_conc = 4. | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/usr/bin/env python | ||
|
||
"""Defines a function to generate a SACC file for cluster number counts.""" | ||
|
||
# # Cluster count-only SACC file creation | ||
# | ||
# This notebook examplifies the creation of a SACC file for cluster count, using | ||
# NumCosmo facilities to simulate cluster data. | ||
|
||
import itertools | ||
|
||
from numcosmo_py import Nc | ||
from numcosmo_py import Ncm | ||
|
||
from typing import Any | ||
import sacc | ||
|
||
|
||
def convert_binned_profile_to_sacc( | ||
cluster_counts, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add type hints for the function arguments, so that |
||
mean_DeltaSigma, | ||
covariance, | ||
z_edges, | ||
richness_edges, | ||
radius_edges, | ||
radius_centers, | ||
area, | ||
survey_name="numcosmo_simulated_redshift_richness", | ||
) -> sacc.Sacc: | ||
N_z = len(z_edges) - 1 | ||
N_richness = len(richness_edges) - 1 | ||
N_radius = len(radius_edges) - 1 | ||
|
||
# Prepare the SACC file | ||
s_count = sacc.Sacc() | ||
bin_z_labels = [] | ||
bin_richness_labels = [] | ||
bin_radius_labels = [] | ||
|
||
s_count.add_tracer("survey", survey_name, area) | ||
|
||
for i, z_bin in enumerate(zip(z_edges[:-1], z_edges[1:])): | ||
lower, upper = z_bin | ||
bin_z_label = f"bin_z_{i}" | ||
s_count.add_tracer("bin_z", bin_z_label, lower, upper) | ||
bin_z_labels.append(bin_z_label) | ||
|
||
for i, richness_bin in enumerate(zip(richness_edges[:-1], richness_edges[1:])): | ||
lower, upper = richness_bin | ||
bin_richness_label = f"rich_{i}" | ||
s_count.add_tracer("bin_richness", bin_richness_label, lower, upper) | ||
bin_richness_labels.append(bin_richness_label) | ||
|
||
for i, (radius_lower, radius_upper, radius_center) in enumerate( | ||
zip(radius_edges[:-1], radius_edges[1:], radius_centers) | ||
): | ||
bin_radius_label = f"bin_radius_{i}" | ||
s_count.add_tracer( | ||
"bin_radius", bin_radius_label, radius_lower, radius_upper, radius_center | ||
) | ||
bin_radius_labels.append(bin_radius_label) | ||
|
||
# pylint: disable-next=no-member | ||
type_cluster_counts = sacc.standard_types.cluster_counts | ||
# pylint: disable-next=no-member | ||
type_cluster_DeltaSigma = sacc.standard_types.cluster_shear | ||
|
||
for counts, (bin_z_label, bin_richness_label) in zip( | ||
cluster_counts.flatten(), itertools.product(bin_z_labels, bin_richness_labels) | ||
): | ||
s_count.add_data_point( | ||
type_cluster_counts, | ||
(survey_name, bin_z_label, bin_richness_label), | ||
int(counts), | ||
) | ||
|
||
for profile, (bin_z_label, bin_richness_label) in zip( | ||
mean_DeltaSigma.reshape(N_richness * N_z, N_radius), | ||
itertools.product(bin_z_labels, bin_richness_labels), | ||
): | ||
for profile_value, bin_radius_label in zip(profile, bin_radius_labels): | ||
s_count.add_data_point( | ||
type_cluster_DeltaSigma, | ||
(survey_name, bin_z_label, bin_richness_label, bin_radius_label), | ||
profile_value, | ||
) | ||
|
||
# ### Then the add the covariance and save the file | ||
|
||
s_count.add_covariance(covariance) | ||
s_count.to_canonical_order() | ||
return s_count | ||
|
||
|
||
if __name__ == "__main__": | ||
Ncm.cfg_init() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file declares a
main
, but it doesn't seem to be an actual program that does something when invoked.Is there something missing, or should the
main
be removed?If it is removed, then the shebang line can also be removed.
The documentation also says this is a notebook -- it appears some of the documentation is stale and in need of review.