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 .github/workflows/build_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- name: Install prereq and NumCosmo using conda
run: |
echo "$CONDA/bin" >> $GITHUB_PATH
conda install -c conda-forge gobject-introspection pygobject 'numcosmo<=0.22.0' cmake swig setuptools_scm
conda install -c conda-forge gobject-introspection pygobject 'numcosmo<=0.24' cmake swig setuptools_scm
- name: Install prereq using pip
run: |
pip install -r requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion clmm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
)
from .utils import compute_radial_averages, convert_units, make_bins

__version__ = "1.16.8"
__version__ = "1.16.9"
28 changes: 15 additions & 13 deletions clmm/theory/numcosmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,17 @@ def __init__(
Ncm.cfg_init()
self.backend = "nc"
self.mdef_dict = {
"mean": Nc.HaloDensityProfileMassDef.MEAN,
"critical": Nc.HaloDensityProfileMassDef.CRITICAL,
"virial": Nc.HaloDensityProfileMassDef.VIRIAL,
"mean": Nc.HaloMassSummaryMassDef.MEAN,
"critical": Nc.HaloMassSummaryMassDef.CRITICAL,
"virial": Nc.HaloMassSummaryMassDef.VIRIAL,
}
self.hdpm_dict = {
"nfw": Nc.HaloDensityProfileNFW.new,
"einasto": Nc.HaloDensityProfileEinasto.new,
"hernquist": Nc.HaloDensityProfileHernquist.new,
}
self.cosmo_class = NumCosmoCosmology
self._hms = None
# Set halo profile and cosmology
self.set_halo_density_profile(halo_profile_model, massdef, delta_mdef)
self.set_cosmo(None)
Expand All @@ -76,34 +77,35 @@ def _update_halo_density_profile(self):
has_cm_vals = self.hdpm is not None
if has_cm_vals:
cdelta = self.cdelta
log10_mdelta = self.hdpm.props.log10MDelta
log10_mdelta = self._hms.props.log10MDelta

self.hdpm = self.hdpm_dict[self.halo_profile_model](
self.mdef_dict[self.massdef], self.delta_mdef
)
self._hms = Nc.HaloCMParam.new(self.mdef_dict[self.massdef], self.delta_mdef)

self.hdpm = self.hdpm_dict[self.halo_profile_model](self._hms)

if has_cm_vals:
self.cdelta = cdelta
self.hdpm.props.log10MDelta = log10_mdelta
self._hms.props.cDelta = cdelta
self._hms.props.log10MDelta = log10_mdelta

self._update_vec_funcs()

def _get_concentration(self):
"""get concentration"""
return self.hdpm.props.cDelta
return self._hms.props.cDelta

def _get_mass(self):
"""get mass"""
return 10**self.hdpm.props.log10MDelta
return 10**self._hms.props.log10MDelta

def _set_concentration(self, cdelta):
"""set concentration"""
self.hdpm.props.cDelta = cdelta
self._hms.props.cDelta = cdelta
self._update_vec_funcs()

def _set_mass(self, mdelta):
"""set mass"""
self.hdpm.props.log10MDelta = math.log10(mdelta)
self._hms.props.log10MDelta = math.log10(mdelta)
self._update_vec_funcs()

def _set_einasto_alpha(self, alpha):
Expand All @@ -122,7 +124,7 @@ def _get_delta_mdef_virial(self, z_cl):
"Gets the virial overdensity"
# This fuction can return the overdensity for all mass definitions,
# but in CLMM, we only use it in the case of massdef='virial'.
return self.hdpm.Delta(self.cosmo.be_cosmo, z_cl)
return self._hms.Delta(self.cosmo.be_cosmo, z_cl)

def _eval_reduced_tangential_shear_core(self, r_proj, z_cl, z_src):
"""eval reduced tangential shear considering a single redshift plane
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,8 @@
"mset2 = ggt2.moo.get_mset()\n",
"\n",
"# Parameters: cluster mass (log base 10) and concentration\n",
"log10MDelta_pi = mset1.param_get_by_full_name(\"NcHaloDensityProfile:log10MDelta\")\n",
"cDelta_pi = mset1.param_get_by_full_name(\"NcHaloDensityProfile:cDelta\")\n",
"log10MDelta_pi = mset1.param_get_by_full_name(\"NcHaloMassSummary:log10MDelta\")\n",
"cDelta_pi = mset1.param_get_by_full_name(\"NcHaloMassSummary:cDelta\")\n",
"\n",
"mset1.param_set_ftype(log10MDelta_pi.mid, log10MDelta_pi.pid, Ncm.ParamType.FREE)\n",
"mset1.param_set_ftype(cDelta_pi.mid, cDelta_pi.pid, Ncm.ParamType.FIXED)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,8 @@
"mset3 = ggt3.moo.get_mset()\n",
"\n",
"# Parameters: cluster mass (log base 10) and concentration\n",
"MDelta_pi = mset1.param_get_by_full_name(\"NcHaloDensityProfile:log10MDelta\")\n",
"cDelta_pi = mset1.param_get_by_full_name(\"NcHaloDensityProfile:cDelta\")\n",
"MDelta_pi = mset1.param_get_by_full_name(\"NcHaloMassSummary:log10MDelta\")\n",
"cDelta_pi = mset1.param_get_by_full_name(\"NcHaloMassSummary:cDelta\")\n",
"\n",
"mset1.param_set_ftype(MDelta_pi.mid, MDelta_pi.pid, Ncm.ParamType.FREE)\n",
"mset1.param_set_ftype(cDelta_pi.mid, cDelta_pi.pid, Ncm.ParamType.FREE)\n",
Expand Down
225 changes: 34 additions & 191 deletions examples/NumCosmo/modeling_cmp_numcosmo.ipynb

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions examples/other_compare_NFW_critical_massdef.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,10 @@
"lnXf = math.log(1.0e4)\n",
"improve_prec = True\n",
"\n",
"nc_nfw = Nc.HaloDensityProfileNFW.new(Nc.HaloDensityProfileMassDef.CRITICAL, Delta)\n",
"nc_nfw.props.cDelta = cvir\n",
"nc_nfw.props.log10MDelta = math.log10(Mvir)\n",
"nc_hms = Nc.HaloCMParam.new(Nc.HaloMassSummaryMassDef.CRITICAL, Delta)\n",
"nc_nfw = Nc.HaloDensityProfileNFW.new(nc_hms)\n",
"nc_hms.props.cDelta = cvir\n",
"nc_hms.props.log10MDelta = math.log10(Mvir)\n",
"\n",
"if improve_prec:\n",
" nc_nfw.set_reltol(reltol)\n",
Expand Down
6 changes: 3 additions & 3 deletions tests/test_theory_parent.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ def test_instantiate(modeling_data):
reduced_shear = mod.eval_reduced_tangential_shear(r_proj, z_cl, z_src)
magnification = mod.eval_magnification(r_proj, z_cl, z_src)

assert_allclose(reduced_shear, shear / (1.0 - convergence), rtol=1.0e-12)
assert_allclose(reduced_shear, shear / (1.0 - convergence), rtol=1.0e-11)
assert_allclose(
magnification, 1.0 / ((1.0 - convergence) ** 2 - np.abs(shear) ** 2), rtol=1.0e-12
magnification, 1.0 / ((1.0 - convergence) ** 2 - np.abs(shear) ** 2), rtol=1.0e-11
)

reduced_shear = mod.eval_reduced_tangential_shear(r_proj, z_cl, np.full_like(r_proj, z_src))
assert_allclose(reduced_shear, shear / (1.0 - convergence), rtol=1.0e-12)
assert_allclose(reduced_shear, shear / (1.0 - convergence), rtol=1.0e-11)


def test_einasto(modeling_data):
Expand Down
Loading