Skip to content

Commit

Permalink
Merge branch 'joezuntz:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
aferte authored Jan 19, 2024
2 parents db35988 + 1a28007 commit 60e434b
Show file tree
Hide file tree
Showing 46 changed files with 4,314 additions and 1,114 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ jobs:
source cosmosis-configure
make
- name: Install likelihood python dependencies from pip
shell: bash -l {0}
run: |
pip install "act_dr6_lenslike>=1.0.2"
- name: Run Tests
shell: bash -l {0}
run: |
Expand Down Expand Up @@ -229,6 +234,10 @@ jobs:
pip install -v --no-cache-dir --no-binary=mpi4py,camb mpi4py camb
pip install fitsio astropy fast-pt "Cython<3.0" jupyter
- name: Install likelihood python dependencies
run: |
pip install "act_dr6_lenslike>=1.0.2"
- name: Build
run: |
source .github/ci-setup.sh && make
Expand Down
36 changes: 22 additions & 14 deletions boltzmann/camb/camb_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ def get_choice(options, name, valid, default=None, prefix=''):
raise ValueError("Parameter setting '{}' in camb must be one of: {}. You tried: {}".format(name, valid, choice))
return prefix + choice


def make_z_for_pk(more_config):
if "zmid" in more_config:
z = np.concatenate((np.linspace(more_config['zmin'],
more_config['zmid'],
more_config['nz_mid'],
endpoint=False),
np.linspace(more_config['zmid'],
more_config['zmax'],
more_config['nz']-more_config['nz_mid'])))[::-1]
else:
z = np.linspace(more_config['zmin'], more_config['zmax'], more_config["nz"])[::-1]

return z


def setup(options):
mode = options.get_string(opt, 'mode', default="all")
if not mode in MODES:
Expand Down Expand Up @@ -162,7 +178,8 @@ def setup(options):
more_config["transfer_params"]["kmax"] = options.get_double(opt, "kmax", default=10.0)
# more_config["transfer_params"]["high_precision"] = options.get_bool(opt, "high_precision", default=True)

more_config['kmin'] = options.get_double(opt, "kmin", default=1e-5)
if options.has_value(opt, "kmin"):
warnings.warn("Option kmin does not have an effect.")
more_config['kmax'] = options.get_double(opt, "kmax", more_config["transfer_params"]["kmax"])
more_config['kmax_extrapolate'] = options.get_double(opt, "kmax_extrapolate", default=more_config['kmax'])
more_config['nk'] = options.get_int(opt, "nk", default=200)
Expand Down Expand Up @@ -400,17 +417,7 @@ def extract_camb_params(block, config, more_config):
p.set_accuracy(**more_config["accuracy_params"])

if want_perturbations:
if "zmid" in more_config:
z = np.concatenate((np.linspace(more_config['zmin'],
more_config['zmid'],
more_config['nz_mid'],
endpoint=False),
np.linspace(more_config['zmid'],
more_config['zmax'],
more_config['nz']-more_config['nz_mid'])))[::-1]
else:
z = np.linspace(more_config['zmin'], more_config['zmax'], more_config["nz"])[::-1]

z = make_z_for_pk(more_config)
p.set_matter_power(redshifts=z, nonlinear=config["NonLinear"] in ["NonLinear_both", "NonLinear_pk"], **more_config["transfer_params"])

return p
Expand Down Expand Up @@ -530,8 +537,7 @@ def save_matter_power(r, block, more_config):
# and the max one extrapolated out too. We output to the larger
# of these
kmax_power = max(more_config['kmax'], more_config['kmax_extrapolate'])
k = np.logspace(np.log10(more_config['kmin']), np.log10(kmax_power), more_config['nk'])
z = np.linspace(more_config['zmin'], more_config['zmax'], more_config['nz'])
z = make_z_for_pk(more_config)[::-1]

P_tot = None

Expand All @@ -547,6 +553,8 @@ def save_matter_power(r, block, more_config):
extrap_kmax=more_config['kmax_extrapolate']
)
assert P.islog
k = np.logspace(np.log10(kcalc[0]), np.log10(kmax_power), more_config['nk'])

# P.P evaluates at k instead of logk
p_k = P.P(z, k, grid=True)

Expand Down
24 changes: 24 additions & 0 deletions examples/bacco-values.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[cosmological_parameters]
omega_m = 0.3
h0 = 0.7
omega_b = 0.048
n_s = 0.97
A_s = 2.19e-9
w = -1.0
wa = 0.0
; New parametrization and names:
mnu = 0.0773
num_massive_neutrinos = 3
nnu = 3.046

omega_k = 0.0
tau = 0.0697186

[baryon_parameters]
M_c = 9.0 14.0 15.0
eta = -0.698 -0.3 0.698
beta = -1.0 -0.22 0.698
M1_z0_cen= 9.0 10.5 13.0
theta_out= 0.0 0.25 0.477
theta_inn = -2.0 -0.86 -0.522
M_inn = 9.0 13.4 13.5
54 changes: 54 additions & 0 deletions examples/bacco.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[runtime]
sampler = test
verbosity = debug

[apriori]
nsample = 100

[output]
filename = output/bacco.txt

[pipeline]
modules = consistency bbn_consistency camb extrapolate bacco_emulator

timing=F
debug=F

values = examples/bacco-values.ini
extra_output =

[test]
save_dir=output/bacco
fatal_errors=T

[consistency]
file = utility/consistency/consistency_interface.py

[bbn_consistency]
file = utility/bbn_consistency/bbn_consistency.py

[camb]
file = boltzmann/camb/camb_interface.py
mode = power
lmax = 2500 ;max ell to use for cmb calculation
feedback=0 ;amount of output to print
AccuracyBoost=1.1 ;CAMB accuracy boost parameter
do_tensors = T
do_lensing = T
NonLinear = none
zmin_background = 0.
zmax_background = 4.
nz_background = 401
kmin=1e-4
kmax = 50.0
kmax_extrapolate = 500.0
nk=700
nz = 150

[extrapolate]
file = boltzmann/extrapolate/extrapolate_power.py
kmax = 500.

[bacco_emulator]
file = structure/baccoemu/baccoemu_interface.py
mode = nonlinear
38 changes: 38 additions & 0 deletions examples/des-campaign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,35 @@ runs:
params:
- sampler = test

- name: bacco-nl
parent: fiducial
params:
- bacco.file = structure/baccoemu/baccoemu_interface.py
- bacco.mode = nonlinear
- camb.nonlinear = none
pipeline:
- after camb bacco

- name: bacco-baryons
parent: fiducial
components:
- bacco_baryon_params
params:
- bacco.file = structure/baccoemu/baccoemu_interface.py
- bacco.mode = baryons
pipeline:
- after camb bacco

- name: bacco-nl-baryons
parent: fiducial
components:
- bacco_baryon_params
params:
- bacco.file = structure/baccoemu/baccoemu_interface.py
- bacco.mode = nonlinear+baryons
pipeline:
- after camb bacco

# This run is based on the fiducial run above, with
# additional changes applied to it on top of the ones above
- name: class
Expand Down Expand Up @@ -120,6 +149,15 @@ runs:

# These components can be re-used in multiple runs above.
components:
bacco_baryon_params:
values:
- baryon_parameters.M_c = 9.0 14.0 15.0
- baryon_parameters.eta = -0.698 -0.3 0.698
- baryon_parameters.beta = -1.0 -0.22 0.698
- baryon_parameters.M1_z0_cen= 9.0 10.5 13.0
- baryon_parameters.theta_out= 0.0 0.25 0.477
- baryon_parameters.theta_inn = -2.0 -0.86 -0.522
- baryon_parameters.M_inn = 9.0 13.4 13.5
maglim_cuts:
params:
- 2pt_like.angle_range_xip_1_1 = 2.475 999.0
Expand Down
Loading

0 comments on commit 60e434b

Please sign in to comment.