Skip to content

Commit bb7b0c2

Browse files
committed
Updates to likelihood
1 parent 991e3ca commit bb7b0c2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

cobaya_interface/likelihood.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import fnmatch
66

77
import matplotlib.pyplot as plt
8-
from vega.vega_interface_mod import VegaInterface
8+
from vega.vega_interface import VegaInterface
99

1010
import scipy
1111
from scipy.interpolate import interp1d, InterpolatedUnivariateSpline
@@ -18,9 +18,9 @@ def initialize(self, **params_values):
1818
'''
1919
Set up initial parameters
2020
'''
21-
self.vega = VegaInterface('simple_example/complex_main.ini') # Creates an instance of VegaInterface with a configuration file containing cosmological or model parameters
22-
self.effective_redshift = 2.3
23-
self.k_grid = np.logspace(-4,2,700) # grid of scales for power spectrum
21+
self.vega = VegaInterface('cobaya_interface/configs/complex_main.ini') # Creates an instance of VegaInterface with a configuration file containing cosmological or model parameters
22+
self.effective_redshift = 2.33
23+
self.k_grid = np.logspace(-4,3.061640934061686,814) #np.logspace(-4,2,700) # grid of scales for power spectrum
2424
self.vega.fiducial['z_fiducial'] = self.effective_redshift # fix z_eff z_fiducial
2525

2626

@@ -30,7 +30,7 @@ def get_requirements(self):
3030
'''
3131
return {'bias_LYA': None, 'beta_LYA': None,'D_M_fid': None, 'D_H_fid': None, 'or_photon':None, 'or_neutrino':None, \
3232
'H0': None, 'ombh2': None , 'omch2': None, 'omnuh2': None, 'omk': None,'As': None, 'ns': None, \
33-
'Pk_grid': {'z': [self.effective_redshift], 'k_max':100, 'nonlinear':[False]},
33+
'Pk_grid': {'z': [self.effective_redshift], 'k_max':10**3.061640934061686, 'nonlinear':[False]},
3434
'angular_diameter_distance':{'z': [self.effective_redshift]}, 'Hubble':{'z': [self.effective_redshift]},
3535
}
3636

@@ -61,4 +61,6 @@ def logp(self, **params_values):
6161
self.vega.fiducial['Omega_de'] = (1 - params_values['omk'] - params_values['or_photon'] - params_values['or_neutrino'] - omega_m) # computes Omega_de from Omega_m, flatness, photons, and relativistic neutrinos
6262

6363
chi2 = self.vega.chi2(params_values, direct_pk = self.pk_full) # uses vega to compute chi2 from power spectrum and parameter values
64-
return -chi2 / 2 # returns log likelihood
64+
print('param values:', params_values)
65+
print('chi2:', chi2)
66+
return -chi2 / 2 # returns log likelihood

vega/vega_interface.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ def chi2(self, params=None, direct_pk=None):
293293
except utils.VegaBoundsError:
294294
self.models[name].PktoXi.cache_pars = None
295295
return 1e100
296-
297296
if self._use_global_cov:
298297
full_model.append(model_cf)
299298

@@ -324,7 +323,6 @@ def chi2(self, params=None, direct_pk=None):
324323
f"the model. Offending parameter: {param}")
325324
assert param in local_params, err_msg
326325
chi2 += self._gaussian_chi2_prior(local_params[param], prior[0], prior[1])
327-
328326
assert isinstance(chi2, float)
329327
return chi2
330328

0 commit comments

Comments
 (0)