Skip to content

Commit

Permalink
Quick fix to skip mass-richness relation (#79)
Browse files Browse the repository at this point in the history
* add quick fix to skip mass-richness relation

* fix typo in docstring

* fix linebreaks

* fix bad call

* fix typos

* fix linebreaks

* fix lims in cl_cov without mproxy

* update tests

* format code

* add tests

* rm old test

* Requiring pyccl < 2.8.0 due to large amount of breaking changes.

* get has_mproxy from config

* simplify mass_proxy condition
  • Loading branch information
m-aguena committed Jul 19, 2023
1 parent 26e779b commit edee052
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies = [
"pyyaml",
"pytest",
"pytest-rerunfailures",
"pyccl>=2.5.0",
"pyccl>=2.5.0,<2.8.0",
"sacc>=0.8",
"camb",
"healpy",
Expand Down
15 changes: 15 additions & 0 deletions tests/test_covariance_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,21 @@ def test_integral_mass(
assert test == pytest.approx(reference_val, rel=1e-4)


@pytest.mark.parametrize(
"z, reference_val",
[
(0.5, 3.8e-05), # a proper value must be added here
],
)
def test_integral_mass_no_mproxy(
mock_covariance_gauss: CovarianceClusters, z, reference_val
):
mock_covariance_gauss.richness_bins = np.linspace(13.5, 14, 4)
mock_covariance_gauss.has_mproxy = False
test = mock_covariance_gauss.mass_richness_integral(z, 0)
assert test == pytest.approx(reference_val, rel=1e-1)


def test_mass_richness(mock_covariance_gauss: CovarianceClusters):
reference_min = 0.0009528852621284171

Expand Down
19 changes: 14 additions & 5 deletions tjpcov/covariance_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def __init__(self, config, survey_area=4 * np.pi):
cosmo, self.z_lower_limit, self.z_upper_limit
)

# Quick key to skip P(Richness|M)
self.has_mproxy = self.config.get("has_mproxy", True)

def load_from_cosmology(self, cosmo):
"""Values used by the covariance calculation that come from a CCL
cosmology object. Derived attributes from the cosmology are set here.
Expand Down Expand Up @@ -302,21 +305,27 @@ def integrand(ln_m):
)
argument *= halo_bias

mass_richness = self.mass_richness(ln_m, richness_i)
argument *= mass_richness
if self.has_mproxy:
argument *= self.mass_richness(ln_m, richness_i)

return argument

return self._quad_integrate(integrand, self.min_mass, self.max_mass)
if self.has_mproxy:
m_integ_lower, m_integ_upper = self.min_mass, self.max_mass
else:
m_integ_lower = np.log(10) * self.richness_bins[richness_i]
m_integ_upper = np.log(10) * self.richness_bins[richness_i + 1]

return self._quad_integrate(integrand, m_integ_lower, m_integ_upper)

def partial_SSC(self, z, bin_z_j, bin_lbd_j, approx=True):
"""Calculate part of the super sample covariance, or the non-diagonal
correlation between two point functions whose observed modes are larger
than the survey size.
Args:
z1 (float): redshift
bin_z_j (int): redshift bin i
z (float): redshift
bin_z_j (int): redshift bin j
bin_lbd_j (int): richness bin j
approx (bool, optional): Will only calculate the mass richness
integral once and multiply at end. Defaults to True.
Expand Down

0 comments on commit edee052

Please sign in to comment.