Skip to content

Commit

Permalink
v2.final (#1038)
Browse files Browse the repository at this point in the history
* halo profiles in their own directory

* concentrations in their own directory

* mass functions & halo biases in their own directory

* moved CIB stuff to profiles & 2pts

* split halo model into 1/2/4-pt

* fix imports

* remove empty module

* fix typo

* Baryons in v3 (#1039)

* Added new baryons module that will deprecate old BCM

* Tracers v3 (#1040)

* Tracers in V3

* Background, boltzmann, and cls in v3 (#1041)

* Background, boltzmann and cls in v3

* Covariances in v3 (#1046)

* Covariances in V3

* Correlations v3 (#1042)

* Correlations in v3

* split base.py and restructured into its own dir to simplify

* Neutrinos, parameters, power in v3 (#1047)

* done

* Make `T_ncdm` a cosmological parameter + (v3) (#1049)

* first commit

* rename TNCDM to T_ncdm but preserve API

* T_CMB directly into cosmo struct

* Omega_g in ccl_parameters_create; no split between C/Python

* physical_constants.T_CMB doesn't mutate anymore!

* force mutate T_CMB in benchmarks

* define defaults on instantiation just in case constants mutate

* A_s & sigma8: don't play with numbers

* simplify

* remove leftover mallocs

* temporarily preserve API for CCLv3

* Unfreeze option for `physical_constants` (#1050)

* first commit

* update rtd

* addressed comments 1

* Remove `T_CMB` and `T_ncdm` as constants (reloaded) (#1058)

* first commit

* OmNuh2 fix

* addressed comments

* keep only massive

* first step

* temp commit

* debug neutrinos & deprecate Omnuh2

* ccl_omega_x & ccl_Omeganuh2 consistency

---------

Co-authored-by: David Alonso <[email protected]>

* RTD: Removed The Docs

---------

Co-authored-by: David Alonso <[email protected]>

* flaked

---------

Co-authored-by: Nick Koukoufilippas <[email protected]>

* Pk2D and Tk3D in v3 (#1048)

* tk3d and pk2d in v3

---------

Co-authored-by: Nick Koukoufilippas <[email protected]>

* PT biases in v3 (#1056)

* New PT bias framework

* Halos v3 (#1043)

* ported changes in halos/profiles

* changes from star in halos/ (no tests)

* refactor concentration, mass_function, halo_bias; improvements in HMCalculator

* HaloProfile subclasses & HaloProfile.normprof attribute

* simplify imports

* remove HaloProfile.name

* cleaned up pk_Npt

* add extrap_pk argument

* FFTLogParams class instead of dictionary in HaloProfile

* simplified code

* removed mass_def from HMIngredients; comprehensive code review 1

* re-implementation, bugfixes, tests

* c_m_relation >> concentration; code improvements; A_SPLINE_MAX in Python

* HMIngredients initializers - no repeated code

* rogue file

* patch for new changes

* updated Build Status badge website

* fix websites

* added a DOI badge & links

* added nonbreaking space

* removed extra space

* FancyRepr out of CCLObject to simplify

* update tests to match changes

* coverage

* simple test for tkkssc

* more tests for tkkssc

* addressed comments 1

* addressed comments 2: mass_def defaults are name strings etc.

* deprecate Gaussian & PowerLaw profiles

* bugfix in master: sometimes mass_def_strict=False fails unexpectedly

* typo

* addressed comments

* New feature: Arbitrary function for profile normalization

* gain efficiency

* comments + deprecate k_min from HMCalculator

* renamed initialize_from_input --> create_instance

* brought in CCLNamedClass from docs_v3

* brought in from docs_v3: directly callable HMIngredients

* prep for Davids input

* renamed HMCalculator --> HaloModel

* fix typo

* brought in from docs_v3: initialize mass_def from any string (e.g. 400c)

* Revert "renamed HMCalculator --> HaloModel"

This reverts commit 43591ce.

* counterterms func inside of 4pt func

* replace deprecated abstractproperty

* abstract linked methods for HaloProfile, MassFunc, HaloBias, Concentration

* fully working implementation

* renamed lM --> log10M etc.

* minor cosmetic fix

* alternative way to include linked abstract methods and declare the template methods

* reorder

* even simpler

* bring back eq_attrs

* r -> r_t

* Additional halos features (#1068)

* first commit

* enclose classmethods in the class

* brought in minor improvements to halos

* coverage

* Tests v3 (#1059)

* ported changes in halos/profiles

* changes from star in halos/ (no tests)

* refactor concentration, mass_function, halo_bias; improvements in HMCalculator

* HaloProfile subclasses & HaloProfile.normprof attribute

* simplify imports

* remove HaloProfile.name

* cleaned up pk_Npt

* add extrap_pk argument

* FFTLogParams class instead of dictionary in HaloProfile

* simplified code

* removed mass_def from HMIngredients; comprehensive code review 1

* re-implementation, bugfixes, tests

* c_m_relation >> concentration; code improvements; A_SPLINE_MAX in Python

* HMIngredients initializers - no repeated code

* rogue file

* patch for new changes

* updated Build Status badge website

* fix websites

* added a DOI badge & links

* added nonbreaking space

* removed extra space

* FancyRepr out of CCLObject to simplify

* update tests to match changes

* coverage

* simple test for tkkssc

* more tests for tkkssc

* addressed comments 1

* addressed comments 2: mass_def defaults are name strings etc.

* deprecate Gaussian & PowerLaw profiles

* remove all warnings in testing

* use pytest as per docs instead of numpy.testing and pyutils.assert_warns

* bugfix in master: sometimes mass_def_strict=False fails unexpectedly

* typo

* addressed comments

* New feature: Arbitrary function for profile normalization

* gain efficiency

* comments + deprecate k_min from HMCalculator

* renamed initialize_from_input --> create_instance

* brought in CCLNamedClass from docs_v3

* brought in from docs_v3: directly callable HMIngredients

* prep for Davids input

* renamed HMCalculator --> HaloModel

* fix typo

* brought in from docs_v3: initialize mass_def from any string (e.g. 400c)

* Revert "renamed HMCalculator --> HaloModel"

This reverts commit 43591ce.

* comments

* comments

* shortcut for __eq__ methods

* Eq. for EulerianPT calculator (#1073)

* __eq_attrs__ for nl_pt

* No normprof (#1072)

* extricated normprof

* Cosmology v3 (#1071)

* rename core --> Cosmology

* renamed core --> cosmology in docs/imports except docstrings

* cosmology v2

* first pass

* neutrinosneutrinosneutrinos

* simplified

* yamlyamlyaml

* fully fix neutrino mayhem

* new arg names in tests

* comments

* comments on comments on comments

* removed tests

* no warn

---------

Co-authored-by: David Alonso <[email protected]>

* avoid warning due to zeros (#1076)

* Fix halo inconsistencies v3 (#1069)

* ported changes in halos/profiles

* changes from star in halos/ (no tests)

* refactor concentration, mass_function, halo_bias; improvements in HMCalculator

* HaloProfile subclasses & HaloProfile.normprof attribute

* simplify imports

* remove HaloProfile.name

* cleaned up pk_Npt

* add extrap_pk argument

* FFTLogParams class instead of dictionary in HaloProfile

* simplified code

* removed mass_def from HMIngredients; comprehensive code review 1

* re-implementation, bugfixes, tests

* c_m_relation >> concentration; code improvements; A_SPLINE_MAX in Python

* HMIngredients initializers - no repeated code

* rogue file

* patch for new changes

* updated Build Status badge website

* fix websites

* added a DOI badge & links

* added nonbreaking space

* removed extra space

* FancyRepr out of CCLObject to simplify

* update tests to match changes

* coverage

* simple test for tkkssc

* more tests for tkkssc

* addressed comments 1

* addressed comments 2: mass_def defaults are name strings etc.

* deprecate Gaussian & PowerLaw profiles

* bugfix in master: sometimes mass_def_strict=False fails unexpectedly

* typo

* addressed comments

* New feature: Arbitrary function for profile normalization

* gain efficiency

* comments + deprecate k_min from HMCalculator

* renamed initialize_from_input --> create_instance

* brought in CCLNamedClass from docs_v3

* brought in from docs_v3: directly callable HMIngredients

* prep for Davids input

* renamed HMCalculator --> HaloModel

* fix typo

* brought in from docs_v3: initialize mass_def from any string (e.g. 400c)

* Revert "renamed HMCalculator --> HaloModel"

This reverts commit 43591ce.

* counterterms func inside of 4pt func

* replace deprecated abstractproperty

* abstract linked methods for HaloProfile, MassFunc, HaloBias, Concentration

* fully working implementation

* renamed lM --> log10M etc.

* minor cosmetic fix

* first commit

* alternative way to include linked abstract methods and declare the template methods

* reorder

* even simpler

* enclose classmethods in the class

* brought in minor improvements to halos

* clone of 1064

* bring back eq_attrs

* r -> r_t

* Additional halos features (#1068)

* first commit

* enclose classmethods in the class

* brought in minor improvements to halos

* coverage

* removed MassConcentration

* full implementation (v3 only)

* comments

* single-liner

* coverage

* Final checklist v3 (#1075)

* imports

* homogenize all imports as per PEP8 and the Python Import System

* homogenize all imports as per PEP8 and the Python Import System

* instance checks

* all exceptions raised correctly

* comments

* add aliases

* reverted changes and introduced proper enums

* Preserve API in v2.final (#1077)

* first commit

* Einasto mass translator + MassDef concentration API

* universal api no-break

* comments

* MassDef vars

* Coverage v3 (#1078)

* coverage

* comments

---------

Co-authored-by: David Alonso <[email protected]>
  • Loading branch information
nikfilippas and damonge authored May 3, 2023
1 parent 1a351df commit f81b59a
Show file tree
Hide file tree
Showing 183 changed files with 11,139 additions and 11,065 deletions.
4 changes: 3 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[flake8]
ignore = E741,E226,W503,W504
exclude =
per-file-ignores =
*/__init__.py:F401,F403,
exclude =
build/,
.eggs/,
benchmarks/data,
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ option(FORCE_OPENMP "Forcibly use OpenMP " NO)
set(CCL_SRC
src/ccl_background.c src/ccl_core.c src/ccl_error.c
src/ccl_bbks.c src/ccl_f1d.c src/ccl_f2d.c src/ccl_f3d.c
src/ccl_power.c src/ccl_bcm.c
src/ccl_power.c
src/ccl_eh.c src/ccl_musigma.c
src/ccl_utils.c src/ccl_cls.c src/ccl_massfunc.c
src/ccl_neutrinos.c
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ STYLE CONVENTION USED
**`type`** or **`structure`**
-->
# CCL
[![Build Status](https://travis-ci.org/LSSTDESC/CCL.svg?branch=master)](https://travis-ci.org/LSSTDESC/CCL) [![Coverage Status](https://coveralls.io/repos/github/LSSTDESC/CCL/badge.svg?branch=master)](https://coveralls.io/github/LSSTDESC/CCL?branch=master) [![Documentation Status](https://readthedocs.org/projects/ccl/badge/?version=latest)](https://ccl.readthedocs.io/en/latest/?badge=latest)
![Build](https://github.com/LSSTDESC/CCL/workflows/continuous-integration/badge.svg?branch=master)&nbsp;
[![Coverage](https://coveralls.io/repos/github/LSSTDESC/CCL/badge.svg?branch=master)](https://coveralls.io/github/LSSTDESC/CCL?branch=master)&nbsp;
[![Documentation](https://readthedocs.org/projects/ccl/badge/?version=latest)](https://ccl.readthedocs.io/en/latest/)&nbsp;
[![DOI](https://img.shields.io/badge/DOI-10.3847%2F1538--4365%2Fab1658-B31B1B.svg)](https://iopscience.iop.org/article/10.3847/1538-4365/ab1658)

The Core Cosmology Library (CCL) is a standardized library of routines to calculate
basic observables used in cosmology. It will be the standard analysis package used by the
Expand Down
18 changes: 9 additions & 9 deletions benchmarks/ccl_test_angpow.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#include <math.h>

#define NZ 1024
#define Z0_GC 1.0
#define Z0_GC 1.0
#define SZ_GC 0.02
#define NL 499

#define CLS_PRECISION 3E-3
#define CLS_PRECISION 3E-3

CTEST_DATA(angpow) {
double Omega_c;
Expand All @@ -30,7 +30,7 @@ CTEST_DATA(angpow) {



// Set up the cosmological parameters to be used
// Set up the cosmological parameters to be used
CTEST_SETUP(angpow){
data->Omega_c = 0.25;
data->Omega_b = 0.05;
Expand All @@ -55,7 +55,7 @@ static void test_angpow_precision(struct angpow_data * data)
{
// Status flag
int status =0;

// Initialize cosmological parameters
ccl_configuration ccl_config=default_config;
ccl_config.transfer_function_method=ccl_boltzmann_class;
Expand All @@ -78,7 +78,7 @@ static void test_angpow_precision(struct angpow_data * data)
nz_arr_gc[i]=exp(-0.5*pow((z_arr_gc[i]-Z0_GC)/SZ_GC,2));
bz_arr[i]=1;
}

// Galaxy clustering tracer
CCL_ClTracer *ct_gc_A=ccl_cl_tracer_number_counts(ccl_cosmo,1,1,0,
NZ,z_arr_gc,nz_arr_gc,
Expand All @@ -88,7 +88,7 @@ static void test_angpow_precision(struct angpow_data * data)
NZ,z_arr_gc,nz_arr_gc,
NZ,z_arr_gc,bz_arr,
-1,NULL,NULL, &status);

int *ells=malloc(NL*sizeof(int));
double *cells_gg_angpow=malloc(NL*sizeof(double));
for(int ii=0;ii<NL;ii++)
Expand All @@ -98,7 +98,7 @@ static void test_angpow_precision(struct angpow_data * data)
// Workspaces
double linstep = 40;
double logstep = 1.15;

// Compute C_ell
ccl_angular_cls_nonlimber(ccl_cosmo,logstep,linstep,
ct_gc_A,ct_gc_A,NULL,
Expand All @@ -117,13 +117,13 @@ static void test_angpow_precision(struct angpow_data * data)
fclose(f);
rel_precision /= NL;
ASSERT_TRUE(rel_precision < CLS_PRECISION);

//Free up tracers
ccl_cl_tracer_free(ct_gc_A);
ccl_cl_tracer_free(ct_gc_B);
free(ells);
free(cells_gg_angpow);
ccl_cosmology_free(ccl_cosmo);
ccl_cosmology_free(ccl_cosmo);
}

CTEST2(angpow,precision) {
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/ccl_test_f2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ CTEST2(f2d,pk) {
config.matter_power_spectrum_method = ccl_linear;
ccl_parameters params = ccl_parameters_create(data->Omega_c,data->Omega_b, 0.0, 3.046, &mnu,
0, -1.0, 0.0, data->h, data->A_s,data->n_s,
-1, -1, -1, 0., 0., 1.0, 1.0, 0.0,
-1, -1, -1, 0., 0., 1.0, 1.0, 0.0,
-1, NULL, NULL, &status);
params.T_CMB=2.7;
params.Omega_k=0;
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/test_bbks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_bbks(model, w0, wa):
w0=w0,
wa=wa,
T_CMB=2.7,
m_nu_type='normal',
mass_split='normal',
Omega_g=0,
Omega_k=0,
transfer_function='bbks',
Expand Down
28 changes: 7 additions & 21 deletions benchmarks/test_bcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,7 @@ def test_bcm():
A_s=2.2e-9,
n_s=0.96,
Neff=3.046,
m_nu_type='normal',
m_nu=0.0,
Omega_g=0,
Omega_k=0,
w0=-1,
wa=0,
bcm_log10Mc=14.0,
baryons_power_spectrum='bcm')

cosmo_nobar = ccl.Cosmology(
Omega_c=0.25,
Omega_b=0.05,
h=0.7,
A_s=2.2e-9,
n_s=0.96,
Neff=3.046,
m_nu_type='normal',
mass_split='normal',
m_nu=0.0,
Omega_g=0,
Omega_k=0,
Expand All @@ -41,12 +25,14 @@ def test_bcm():
k = data[:, 0] * cosmo['h']
a = 1

fbcm = ccl.bcm_model_fka(cosmo, k, a)
bar = ccl.BaryonsSchneider15(log10Mc=14.)
fbcm = bar.boost_factor(cosmo, k, a)
err = np.abs(data[:, 1]/data_nobar[:, 1]/fbcm - 1)
assert np.allclose(err, 0, atol=BCM_TOLERANCE, rtol=0)

ratio = (
ccl.nonlin_matter_power(cosmo, k, a) /
ccl.nonlin_matter_power(cosmo_nobar, k, a))
cosmo.compute_nonlin_power()
pk_nobar = cosmo.get_nonlin_power()
pk_wbar = bar.include_baryonic_effects(cosmo, pk_nobar)
ratio = pk_wbar(k, a)/pk_nobar(k, a)
err = np.abs(data[:, 1]/data_nobar[:, 1]/ratio - 1)
assert np.allclose(err, 0, atol=BCM_TOLERANCE, rtol=0)
9 changes: 1 addition & 8 deletions benchmarks/test_camb_class_consistent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
import numpy as np
import warnings

import pyccl as ccl

Expand All @@ -17,13 +16,7 @@ def test_camb_class_consistent_smoke(kwargs=None, pkerr=1e-3):
Omega_c=0.25, Omega_b=0.05, h=0.7, n_s=0.95, A_s=2e-9,
transfer_function='boltzmann_class', **kwargs)

with warnings.catch_warnings():
# We do some tests here with massive neutrinos, which currently raises
# a warning.
# XXX: Do you really want to be raising a warning for this?
# This seems spurious to me. (MJ)
warnings.simplefilter("ignore")
rel_sigma8 = np.abs(ccl.sigma8(c_camb) / ccl.sigma8(c_class) - 1)
rel_sigma8 = np.abs(ccl.sigma8(c_camb) / ccl.sigma8(c_class) - 1)

a = 0.845
k = np.logspace(-3, 1, 100)
Expand Down
31 changes: 16 additions & 15 deletions benchmarks/test_cls.py → benchmarks/test_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def set_up(request):

nztyp = request.param
dirdat = os.path.dirname(__file__) + '/data/'
ccl.gsl_params.LENSING_KERNEL_SPLINE_INTEGRATION = False
ccl.gsl_params.INTEGRATION_LIMBER_EPSREL = 1E-4
ccl.gsl_params.INTEGRATION_EPSREL = 1E-4
cosmo = ccl.Cosmology(Omega_c=0.30, Omega_b=0.00, Omega_g=0, Omega_k=0,
Expand Down Expand Up @@ -68,21 +69,21 @@ def set_up(request):

# Initialize tracers
trc = {}
trc['g1'] = ccl.NumberCountsTracer(cosmo, False,
(z1, pz1),
(z2, bz))
trc['g2'] = ccl.NumberCountsTracer(cosmo, False,
(z2, pz2),
(z2, bz))
trc['l1'] = ccl.WeakLensingTracer(cosmo, (z1, pz1))
trc['l2'] = ccl.WeakLensingTracer(cosmo, (z2, pz2))
trc['i1'] = ccl.WeakLensingTracer(cosmo, (z1, pz1),
trc['g1'] = ccl.NumberCountsTracer(cosmo, has_rsd=False,
dndz=(z1, pz1),
bias=(z2, bz))
trc['g2'] = ccl.NumberCountsTracer(cosmo, has_rsd=False,
dndz=(z2, pz2),
bias=(z2, bz))
trc['l1'] = ccl.WeakLensingTracer(cosmo, dndz=(z1, pz1))
trc['l2'] = ccl.WeakLensingTracer(cosmo, dndz=(z2, pz2))
trc['i1'] = ccl.WeakLensingTracer(cosmo, dndz=(z1, pz1),
has_shear=False,
ia_bias=(z1, a1))
trc['i2'] = ccl.WeakLensingTracer(cosmo, (z2, pz2),
trc['i2'] = ccl.WeakLensingTracer(cosmo, dndz=(z2, pz2),
has_shear=False,
ia_bias=(z2, a2))
trc['ct'] = ccl.CMBLensingTracer(cosmo, 1100.)
trc['ct'] = ccl.CMBLensingTracer(cosmo, z_source=1100.)

# Read benchmarks
def read_bm(fname):
Expand Down Expand Up @@ -193,8 +194,8 @@ def read_bm(fname):
('i2', 'i2', 'ii_22', # IA2-IA2
'll_22', 'll_22', 'll_22', 'll_22',
'fl_ll')])
def test_cls(set_up, t1, t2, bm,
a1b1, a1b2, a2b1, a2b2, fl):
def test_cells(set_up, t1, t2, bm,
a1b1, a1b2, a2b1, a2b2, fl):
cosmo, trcs, lfc, bmk = set_up
cl = ccl.angular_cl(cosmo, trcs[t1], trcs[t2], lfc['ells'],
limber_integration_method='qag_quad') * lfc[fl]
Expand All @@ -213,8 +214,8 @@ def test_cls(set_up, t1, t2, bm,
('l2', 'l2', 'll_22', # WL2-WL2
'll_22', 'll_22', 'll_22', 'll_22',
'fl_ll')])
def test_cls_spline(set_up, t1, t2, bm,
a1b1, a1b2, a2b1, a2b2, fl):
def test_cells_spline(set_up, t1, t2, bm,
a1b1, a1b2, a2b1, a2b2, fl):
cosmo, trcs, lfc, bmk = set_up
cl = ccl.angular_cl(cosmo, trcs[t1], trcs[t2], lfc['ells'],
limber_integration_method='spline') * lfc[fl]
Expand Down
18 changes: 10 additions & 8 deletions benchmarks/test_cib.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ def test_cibcl():
A_s=2.02E-9,
Neff=3.046)
mdef = ccl.halos.MassDef200m()
cM = ccl.halos.ConcentrationDuffy08(mdef)
nM = ccl.halos.MassFuncTinker10(cosmo, mdef, norm_all_z=True)
bM = ccl.halos.HaloBiasTinker10(cosmo, mdef)
hmc = ccl.halos.HMCalculator(cosmo, nM, bM, mdef)
pr = ccl.halos.HaloProfileCIBShang12(cM, 217, Mmin=1E10)
cM = ccl.halos.ConcentrationDuffy08(mass_def=mdef)
nM = ccl.halos.MassFuncTinker10(mass_def=mdef, norm_all_z=True)
bM = ccl.halos.HaloBiasTinker10(mass_def=mdef)
hmc = ccl.halos.HMCalculator(mass_function=nM, halo_bias=bM,
mass_def=mdef)
pr = ccl.halos.HaloProfileCIBShang12(concentration=cM, nu_GHz=217,
Mmin=1E10)
pr.update_parameters(nu_GHz=217,
alpha=0.36,
T0=24.4,
beta=1.75,
gamma=1.7,
s_z=3.6,
log10meff=12.6,
sigLM=np.sqrt(0.5),
log10Meff=12.6,
siglog10M=np.sqrt(0.5),
Mmin=1E10,
L0=6.4E-8)

Expand All @@ -41,7 +43,7 @@ def test_cibcl():

# Angular power spectrum
ls = bm[0]
cl = ccl.angular_cl(cosmo, tr, tr, ls, p_of_k_a=pk)
cl = ccl.angular_cl(cosmo, tr, tr, ell=ls, p_of_k_a=pk)
dl = cl*ls*(ls+1)/(2*np.pi)

# Compare
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/test_concentration_Ishiyama21.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ def test_concentration_Ishiyama21(pars):

hmd = ccl.halos.MassDef(Delta, "critical")

cm = ccl.halos.ConcentrationIshiyama21(mdef=hmd,
cm = ccl.halos.ConcentrationIshiyama21(mass_def=hmd,
relaxed=pars["relaxed"],
Vmax=pars["Vmax"])

for i, zz in enumerate(Z):
dat = data[:, i+1]
mod = cm.get_concentration(COSMO, M_use/H100, 1/(1+zz))
mod = cm(COSMO, M_use/H100, 1/(1+zz))
assert np.allclose(mod, dat, rtol=UCHUU_DATA_SCATTER)
28 changes: 13 additions & 15 deletions benchmarks/test_correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def set_up(request):
t0 = time.time()
nztyp = request.param
dirdat = os.path.dirname(__file__) + '/data/'
ccl.gsl_params.LENSING_KERNEL_SPLINE_INTEGRATION = False
ccl.gsl_params.INTEGRATION_LIMBER_EPSREL = 2.5E-5
ccl.gsl_params.INTEGRATION_EPSREL = 2.5E-5
cosmo = ccl.Cosmology(Omega_c=0.30, Omega_b=0.00, Omega_g=0, Omega_k=0,
Expand Down Expand Up @@ -71,21 +72,21 @@ def set_up(request):

# Initialize tracers
trc = {}
trc['g1'] = ccl.NumberCountsTracer(cosmo, False,
(z1, pz1),
(z2, bz))
trc['g2'] = ccl.NumberCountsTracer(cosmo, False,
(z2, pz2),
(z2, bz))
trc['l1'] = ccl.WeakLensingTracer(cosmo, (z1, pz1))
trc['l2'] = ccl.WeakLensingTracer(cosmo, (z2, pz2))
trc['i1'] = ccl.WeakLensingTracer(cosmo, (z1, pz1),
trc['g1'] = ccl.NumberCountsTracer(cosmo, has_rsd=False,
dndz=(z1, pz1),
bias=(z2, bz))
trc['g2'] = ccl.NumberCountsTracer(cosmo, has_rsd=False,
dndz=(z2, pz2),
bias=(z2, bz))
trc['l1'] = ccl.WeakLensingTracer(cosmo, dndz=(z1, pz1))
trc['l2'] = ccl.WeakLensingTracer(cosmo, dndz=(z2, pz2))
trc['i1'] = ccl.WeakLensingTracer(cosmo, dndz=(z1, pz1),
has_shear=False,
ia_bias=(z1, a1))
trc['i2'] = ccl.WeakLensingTracer(cosmo, (z2, pz2),
trc['i2'] = ccl.WeakLensingTracer(cosmo, dndz=(z2, pz2),
has_shear=False,
ia_bias=(z2, a2))
trc['ct'] = ccl.CMBLensingTracer(cosmo, 1100.)
trc['ct'] = ccl.CMBLensingTracer(cosmo, z_source=1100.)

# Read benchmarks
def read_bm(fname):
Expand Down Expand Up @@ -223,12 +224,9 @@ def test_xi(set_up, corr_method, t1, t2, bm, er, kind, pref):

global T0
t0 = time.time()
xi = ccl.correlation(cosmo, ell, cli, bms['theta'],
xi = ccl.correlation(cosmo, ell=ell, C_ell=cli, theta=bms['theta'],
type=kind, method=method)
T0 += (time.time() - t0)

xi *= pref
assert np.all(np.fabs(xi - bms[bm]) < ers[er] * errfac)

print("time:", T0)
print("time cls:", T0_CLS)
6 changes: 3 additions & 3 deletions benchmarks/test_correlation_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_correlation_3d(model):
sigma8=0.8,
n_s=0.96,
Neff=3.046,
m_nu_type='normal',
mass_split='normal',
Omega_g=0,
Omega_k=1.0 - 0.25 - 0.05 - Omega_v[model],
w0=w_0[model],
Expand All @@ -45,10 +45,10 @@ def test_correlation_3d(model):
zind = int(z)
a = 1.0 / (1 + z)

xi1 = ccl.correlation_3d(cosmo, a, r1)
xi1 = ccl.correlation_3d(cosmo, a=a, r=r1)
err = np.abs(r1*r1*(xi1-data1[:, zind+1]))
assert np.allclose(err, 0, rtol=0, atol=CORR_TOLERANCE1[zind])

xi2 = ccl.correlation_3d(cosmo, a, data2[:, 0])
xi2 = ccl.correlation_3d(cosmo, a=a, r=data2[:, 0])
err = np.abs(r2*r2*(xi2-data2[:, zind+1]))
assert np.allclose(err, 0, rtol=0, atol=CORR_TOLERANCE1[zind])
Loading

0 comments on commit f81b59a

Please sign in to comment.