Skip to content

Commit

Permalink
Update for CCL v3
Browse files Browse the repository at this point in the history
  • Loading branch information
hsinfan1996 committed May 12, 2023
1 parent f1dd6f5 commit c835c49
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion clmm/cosmology/ccl.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def _eval_sigma_crit_core(self, z_len, z_src):
a_len = self.get_a_from_z(z_len)
a_src = self.get_a_from_z(z_src)

return self.be_cosmo.sigma_critical(a_len, a_src)*self.cor_factor
return self.be_cosmo.sigma_critical(a_lens=a_len, a_source=a_src)*self.cor_factor

def _eval_linear_matter_powerspectrum(self, k_vals, redshift):
return ccl.linear_matter_power(
Expand Down
16 changes: 7 additions & 9 deletions clmm/theory/ccl.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ def _update_halo_density_profile(self):
""""updates halo density profile with set internal properties"""
# prepare mdef object
self.mdef = ccl.halos.MassDef(self.delta_mdef, self.mdef_dict[self.massdef])
# adjust it for ccl version > 2.6.1
if parse(ccl.__version__) >= parse('2.6.2dev7'):
ccl.UnlockInstance.Funlock(type(self.mdef), "_concentration_init", True)
# setting concentration (also updates hdpm)
self.cdelta = self.cdelta if self.hdpm else 4.0 # ccl always needs an input concentration

Expand All @@ -104,10 +101,11 @@ def _get_mass(self):

def _set_concentration(self, cdelta):
""""set concentration. Also sets/updates hdpm"""
self.conc = ccl.halos.ConcentrationConstant(c=cdelta, mdef=self.mdef)
self.mdef._concentration_init(self.conc)
self.conc = ccl.halos.ConcentrationConstant(c=cdelta, mass_def=self.mdef)
with ccl.UnlockInstance(self.mdef):
self.mdef.concentration = self.conc
self.hdpm = self.hdpm_dict[self.halo_profile_model](
self.conc, **self.hdpm_opts[self.halo_profile_model])
concentration=self.conc, **self.hdpm_opts[self.halo_profile_model])
self.hdpm.update_precision_fftlog(
padding_lo_fftlog=1e-4, padding_hi_fftlog=1e3)

Expand All @@ -127,7 +125,7 @@ def _get_einasto_alpha(self, z_cl=None):
a_cl = 1 # a_cl does not matter in this case
else:
a_cl = self.cosmo.get_a_from_z(z_cl)
return self.hdpm._get_alpha(self.cosmo.be_cosmo, self.__mdelta_cor, a_cl, self.mdef)
return self.hdpm._get_alpha(self.cosmo.be_cosmo, self.__mdelta_cor, a_cl)

def _eval_3d_density(self, r3d, z_cl):
""""eval 3d density"""
Expand Down Expand Up @@ -169,14 +167,14 @@ def _call_ccl_profile_lens(self, ccl_hdpm_func, radius, z_lens, ndim=2):
a_lens = self.cosmo.get_a_from_z(z_lens)

return ccl_hdpm_func(self.cosmo.be_cosmo, radius/a_lens, self.__mdelta_cor,
a_lens, self.mdef)*self.cor_factor/a_lens**ndim
a_lens)*self.cor_factor/a_lens**ndim

def _call_ccl_profile_lens_src(self, ccl_hdpm_func, radius, z_lens, z_src):
""""call ccl profile functions that depend on the lens and the sources"""
a_lens = self.cosmo.get_a_from_z(z_lens)
a_src = self.cosmo.get_a_from_z(z_src)

return ccl_hdpm_func(self.cosmo.be_cosmo, radius/a_lens, self.__mdelta_cor,
a_lens, a_src, self.mdef)
a_lens=a_lens, a_source=a_src)

Modeling = CCLCLMModeling
2 changes: 2 additions & 0 deletions tests/test_mockdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def test_mock_data():
with warnings.catch_warnings(record=True) as warn:
# Cause all warnings to always be triggered.
warnings.simplefilter("always")
# Filter out warnings from CCL
warnings.filterwarnings("ignore", module='.*(pyccl).*')
# Trigger a warning.
np.random.seed(314)
mock.generate_galaxy_catalog(
Expand Down

0 comments on commit c835c49

Please sign in to comment.