Skip to content

Commit

Permalink
added ability to remove PT calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Sanchez authored and Javier Sanchez committed Jul 11, 2024
1 parent e2eec40 commit 3c953bf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
15 changes: 10 additions & 5 deletions augur/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,13 @@ def f(self, x, labels, pars_fid, sys_fid):
"""
if hasattr(x, "__len__"):
if len(labels) != len(x):
print(len(labels), len(x))
raise ValueError('The labels should have the same length as the parameters!')
else:
if isinstance(labels, list):
raise ValueError('x is a scalar and labels has more than one entry')
if len(labels) > 1:
raise ValueError('x is a scalar and labels has more than one entry')

if isinstance(x, list):
x = np.array(x)
# Scalar variable
if isinstance(x, (float, int)):
_pars = pars_fid.copy()
_sys_pars = sys_fid.copy()
Expand All @@ -165,6 +164,12 @@ def f(self, x, labels, pars_fid, sys_fid):
self.tools.update(pmap)
self.tools.prepare(cosmo)
f_out = self.lk.compute_theory_vector(self.tools)
return np.array(f_out)

if isinstance(x, list):
x = np.array(x)
# Scalar variable

# 1D
if x.ndim == 1:
_pars = pars_fid.copy()
Expand Down Expand Up @@ -208,7 +213,7 @@ def f(self, x, labels, pars_fid, sys_fid):
f_out.append(self.lk.compute_theory_vector(self.tools))
return np.array(f_out)

def get_derivatives(self, force=False, method='stem'):
def get_derivatives(self, force=False, method='5pt_stencil'):
# Compute the derivatives with respect to the parameters in var_pars at x
if (self.derivatives is None) or (force):
if '5pt_stencil' in method:
Expand Down
30 changes: 20 additions & 10 deletions augur/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,17 +346,27 @@ def generate(config, return_all_outputs=False, write_sacc=True):
lk = ConstGaussian(statistics=stats)
# Pass the correct binning/tracers
lk.read(S)
# The newest version of firecrown requires a modeling tool rather than a cosmology
pt_calculator = ccl.nl_pt.EulerianPTCalculator(
with_NC=False,
with_IA=True,
log10k_min=-4, # Leaving defaults for now
log10k_max=2,
nk_per_decade=20,
cosmo=cosmo
)

# Run cosmo to get the power spectra
cosmo.compute_nonlin_power()
tools = ModelingTools(pt_calculator=pt_calculator)

if 'use_pt_calculator' in config['general'].keys():
if config['general']['use_pt_calculator']:
# The newest version of firecrown requires a modeling tool rather than a cosmology
pt_calculator = ccl.nl_pt.EulerianPTCalculator(
with_NC=False,
with_IA=True,
log10k_min=-4, # Leaving defaults for now
log10k_max=2,
nk_per_decade=20,
cosmo=cosmo
)

tools = ModelingTools(pt_calculator=pt_calculator)
else:
tools = ModelingTools()
else:
tools = ModelingTools()
lk.update(sys_params)
tools.update(sys_params)
tools.prepare(cosmo)
Expand Down

0 comments on commit 3c953bf

Please sign in to comment.