CAMB
CAMB copied to clipboard
CAMBError: Error in Fortran called from calc_transfer: binary_search (e.g for optical depth) did not converge: Base range 800.00-2200.0.
Creating the final list to be fed into the pipeline
result_list = idx.tolist()
final_list = list() for val in result_list:
run the pipeline for the given parameters. All results are saved in block
block = pipeline.run_parameters(val)
stats_name_cosmosis = "cosebis"
# read in cosebis from block
nbin_a=block["shear_cl","nbin_a"]
nbin_b=block["shear_cl","nbin_b"]
counter=0
for i_bin in range(1, nbin_a+1):
for j_bin in range(1, nbin_b+1):
name_in="bin_"+str(j_bin)+("_")+str(i_bin)
if(block.has_value(stats_name_cosmosis, name_in)):
th = block[stats_name_cosmosis,name_in]
if(counter==0):
th_all_3=th.copy()
else:
th_all_3=np.hstack((th_all_3,th))
final_list.append(th_all_3)
final_list=np.hstack((th,th_all_3))
counter+=1
sample_S8 took: 0.000 seconds Warning: Integrate_Romberg failed to converge; integral, error, tol: 1.8779214533333051 -2.0412243158021148E-003 1.0000000000000001E-007 Warning: Integrate_Romberg failed to converge; integral, error, tol: 0.72499700489964747 -8.3126111458664553E-006 1.0000000000000001E-007 Warning: Integrate_Romberg failed to converge; integral, error, tol: 1.8779214533333051 -2.0412243158021148E-003 1.0000000000000001E-007 sigma8toAs took: 61.704 seconds Warning: Integrate_Romberg failed to converge; integral, error, tol: 1.8779214533333051 -2.0412243158021148E-003 1.0000000000000001E-007
CAMBError Traceback (most recent call last)
Input In [40], in <cell line: 5>()
4 final_list = list()
5 for val in result_list:
6
7 # run the pipeline for the given parameters. All results are saved in block
----> 8 block = pipeline.run_parameters(val)
10 stats_name_cosmosis = "cosebis"
13 # read in cosebis from block
File ~/base/lib/python3.9/site-packages/cosmosis/runtime/pipeline.py:1110, in LikelihoodPipeline.run_parameters(self, p, check_ranges, all_params)
1097 u"""Assemble :class:DataBlock
data based on parameter values in p
, and run the pipeline on those data.
1098
1099 If check_ranges
is indicated, the function will return None
if
(...)
1106
1107 """
1108 data = self.build_starting_block(p, check_ranges=check_ranges, all_params=all_params)
-> 1110 if self.run(data):
1111 # First run. If we have not set the likelihood names in the parameter
1112 # file then get them from the block
1113 if self.likelihood_names == NO_LIKELIHOOD_NAMES:
1114 self._set_likelihood_names_from_block(data)
File ~/base/lib/python3.9/site-packages/cosmosis/runtime/pipeline.py:631, in Pipeline.run(self, data_package) 628 if self.timing: 629 t1 = time.time() --> 631 status = module.execute(data_package) 633 if status is None: 634 raise ValueError(("A module you ran, '{}', did not return a proper status value.\n"+ 635 "It should return an integer, 0 if everything worked.\n"+ 636 "Sorry to be picky but this kind of thing is important.").format(module))
File ~/base/lib/python3.9/site-packages/cosmosis/runtime/module.py:249, in Module.execute(self, data_block) 247 raise RuntimeError("Must set up module before executing it") 248 if self.data is not None: --> 249 return self.execute_function(data_block, self.data) 250 else: 251 return self.execute_function(data_block)
File ~/Downloads//kcap//cosmosis-standard-library//boltzmann/pycamb/camb_interface.py:342, in execute(block, config) 340 r = camb.get_background(p) 341 else: --> 342 r = camb.get_results(p) 344 # Write derived parameters to cosmological_parameters section 345 derived = r.get_derived_params()
File ~/base/lib/python3.9/site-packages/camb/camb.py:35, in get_results(params) 33 if _debug_params: 34 print(params) ---> 35 res.calc_power_spectra(params) 36 return res
File ~/base/lib/python3.9/site-packages/camb/results.py:333, in CAMBdata.calc_power_spectra(self, params)
326 """
327 Calculates transfer functions and power spectra.
328
329 :param params: optional :class:~.model.CAMBparams
instance with parameters to use
330
331 """
332 if params is not None:
--> 333 self.calc_transfers(params, only_transfers=False)
334 else:
335 self._check_powers()
File ~/base/lib/python3.9/site-packages/camb/results.py:315, in CAMBdata.calc_transfers(self, params, only_transfers, only_time_sources) 312 self._check_powers(params) 313 if CAMBdata_gettransfers(byref(self), byref(params), byref(c_int(1 if only_transfers else 0)), 314 byref(c_int(1 if only_time_sources else 0))): --> 315 config.check_global_error('calc_transfer')
File ~/base/lib/python3.9/site-packages/camb/_config.py:51, in _config.check_global_error(self, reference) 49 reference = '' 50 if err: ---> 51 raise CAMBError(reference + '%s' % err) 52 else: 53 raise CAMBError(reference + 'Error code: %s' % code)
CAMBError: Error in Fortran called from calc_transfer: binary_search (e.g for optical depth) did not converge: Base range 800.00-2200.0.
The above error was gotten when i was trying to pass my LHS sample of data to my cosmosis pipeline, can you please help me to solve this problem
What were the parameters? Perhaps you forgot to fix tau?
import numpy as np import pyDOE as pyDOE
number of parameters and samples
n_params = 7 n_samples = 400000
parameter ranges
obh2 = np.linspace(0.019, 0.026, n_samples) omch2 = np.linspace(0.051, 0.255, n_samples) h0 = np.linspace(0.64, 0.82, n_samples) n_s = np.linspace(0.84, 1.1, n_samples) s_8_input = np.linspace(0.1, 1.3, n_samples) logt_agn = np.linspace(7.6, 8.0, n_samples) A = np.linspace(-6.0, 6.0, n_samples)
LHS grid
AllParams = np.vstack([obh2, omch2, h0, n_s, s_8_input, logt_agn, A]) lhd = pyDOE.lhs(n_params, samples=n_samples, criterion=None) idx = (lhd * n_samples).astype(int) print(type(idx)) print(len(idx))
The above is the range of my cosmosis parameter. i used this code to create LHS, and i pass the idx(which is the LHS sample) to my cosmosis pipeline to generate the theoretical_value(th_all_3). th_all_3 is supposed to be my cosmosis dataset which im going to train using cosmopower but i for the error ...
Please how can you help me fix this err
You need to look at the parameters being sent to CAMB, I can't help with Cosmosis. For a CAMB bug report, sample code just calling CAMB directly is really needed.