Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion crow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
from .recipes.binned_grid import GridBinnedClusterRecipe
from .recipes.binned_parent import BinnedClusterRecipe

__version__ = "1.0.1"
__version__ = "1.0.2"
11 changes: 10 additions & 1 deletion crow/cluster_modules/shear_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def _beta_s_square_mean_exact(self, z_cl):
]
)

def set_beta_s_interp(self, z_min, z_max, n_intep=3):
def set_beta_s_interp(self, z_min, z_max, n_intep=10):

# Note: this will set an interpolator with a fixed cosmology
# must add check to verify consistency with main cosmology
Expand Down Expand Up @@ -307,6 +307,15 @@ def _one_halo_contribution(
radius_center, redshift
)
else:
if self._beta_parameters is None:
raise ValueError(
"Beta parameters must be set in order to compute the reduced shear."
)
if self.use_beta_s_interp and self._beta_s_mean_interp is None:
raise ValueError(
"Interpolation parameters must be set when using the interpolation "
"option for the lens efficiency."
)
beta_s_mean = self.eval_beta_s_mean(redshift)
beta_s_square_mean = self.eval_beta_s_square_mean(redshift)
first_halo_right_centered = clmm_model.eval_reduced_tangential_shear(
Expand Down
2 changes: 0 additions & 2 deletions crow/recipes/binned_exact.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,6 @@ def evaluate_theory_prediction_lensing_profile(
for radius_center in radius_centers:
extra_args.extend([sky_area, radius_center])
self.integrator.extra_args = np.array(extra_args)
if self.cluster_theory._beta_parameters is not None:
self.cluster_theory.set_beta_s_interp(*z_edges)
theory_prediction = self._get_theory_prediction_shear_profile(average_on)
prediction_wrapper = self._get_function_to_integrate_shear_profile(
theory_prediction
Expand Down
25 changes: 25 additions & 0 deletions tests/test_cluster_shear_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,28 @@ def test_cluster_concentration_negative_values():
assert cluster.cluster_concentration is None
# It should NOT be the default 4
assert np.all(cluster._get_concentration(log_m, z) != 4.0)


def test_unset_beta_parameters_error():
"""Test using ClusterShearProfile without beta parameters set."""
cosmo = _TEST_COSMO
hmf = pyccl.halos.MassFuncBocquet16()
log_m = np.array([14.0])
z = np.array([1.0])
radius = 3.0
cluster = ClusterShearProfile(
cosmo, hmf, is_delta_sigma=False, use_beta_s_interp=True
)
with pytest.raises(
ValueError,
match="Beta parameters must be set in order to compute the reduced shear.",
):
cluster.compute_shear_profile(log_m, z, radius)

cluster.set_beta_parameters(10.0)

with pytest.raises(
ValueError,
match="Interpolation parameters must be set when using the interpolation option for the lens efficiency.",
):
cluster.compute_shear_profile(log_m, z, radius)
Loading