Skip to content

Commit

Permalink
fixed normalization bug when using normalized search space
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Sanchez authored and Javier Sanchez committed Oct 31, 2024
1 parent 6dd8800 commit 63456d4
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions augur/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def __init__(self, config, likelihood=None, tools=None, req_params=None,
self.norm_step = norm_step
# Get the fiducial cosmological parameters
self.pars_fid = tools.get_ccl_cosmology().__dict__['_params_init_kwargs']
# CCL Factory placeholder (for newer firecrown)
self.cf = None

# Load the relevant section of the configuration file
self.config = config['fisher']
Expand Down Expand Up @@ -168,7 +170,9 @@ def f(self, x, labels, pars_fid, sys_fid):
x = np.array(x)
# If we normalize the sampling we need to undo the normalization
if self.norm_step:
print(x)
x = self.norm * x + self.par_bounds[:, 0]
print(x)
self.tools.reset()
self.lk.reset()

Expand Down Expand Up @@ -238,7 +242,11 @@ def get_derivatives(self, force=False, method='5pt_stencil', step=None):
else:
raise ValueError(f'Selected method: `{method}` is not available. \
Please select 5pt_stencil or numdifftools.')
return self.derivatives
if self.norm is None:
return self.derivatives
else:
self.derivatives /= self.norm[:, None]
return self.derivatives
else:
return self.derivatives

Expand Down Expand Up @@ -366,7 +374,6 @@ def compute_new_theory_vector(self, _sys_pars, _pars):

extra_dict['mass_split'] = dict_all['mass_split']
dict_all.pop('mass_split')
print(dict_all)
if 'extra_parameters' in dict_all.keys():
if 'camb' in dict_all['extra_parameters'].keys():
extra_dict['camb_extra_params'] = dict_all['extra_parameters']['camb']
Expand All @@ -378,10 +385,11 @@ def compute_new_theory_vector(self, _sys_pars, _pars):
for key in keys:
if (dict_all[key] is None) or (dict_all[key] == 'None'):
dict_all.pop(key)
cf = CCLFactory(**extra_dict)
self.tools = firecrown.modeling_tools.ModelingTools(ccl_factory=cf)
if self.cf is None:
self.cf = CCLFactory(**extra_dict)
self.tools = firecrown.modeling_tools.ModelingTools(ccl_factory=self.cf)
pmap = ParamsMap(dict_all)
cf.update(pmap)
self.cf.update(pmap)
self.tools.update(pmap)
self.tools.prepare()
self.lk.update(pmap)
Expand Down

0 comments on commit 63456d4

Please sign in to comment.