Closed mahtaparsa closed 7 years ago
Hi
Maybe you did not compile the Python wrapper. (make clean; make -j
). Or perhaps the .conf
file that you are using is pointing to a wrong CLASS directory. (i.e. this happens if you made a copy of the CLASS folder to hold your modifications.)
You can test the wrapper from the terminal by the following one-liner:
python -c "from classy import Class; cosmo=Class(); cosmo.set({'outpu':'tCl'});cosmo.compute()"
This generates the same error, since I made a spelling mistake (wrote 'outpu' instead of 'output')
Cheers, Thomas
Dear Thomas, Thanks for your reply. There is no problem with python wrapper, because when I execute : $ python -c 'from classy import Class' , there is no complain. And I think the CLASS directory in the .conf file is correct, because when I tested the montepython for LCDM model (for example running the input files: test.param , example.param or base2015.param) there was no problem and in the log.param file I could see the data.path['cosmo'] in the 'default configuration' part. Actually in my model, dark energy has been considered as a fluid (_fld), and according to the issue #88 , by adding the line: data.cosmo_arguments['Omega_Lambda'] = 0.0 in the base2015.param file, I can run montepython for a fluid dark energy model and get values for w0_fld and cs2_fld . However,there is problem with my new _fld parameter, which has been added to the perturbation equations in order to modify the code, in which the mentioned error would appear. Best
Hi again
You should not just test the wrapper by importing it, but by setting the new parameter and computing. I will assume that you new parameter is called foo_fld
. If I now run:
python -c "from classy import Class; cosmo=Class(); cosmo.set({'output':'tCl', 'Omega_Lambda':0.0,'w0_fld':-0.9});cosmo.compute()"
There is no problem, but if I run
python -c "from classy import Class; cosmo=Class(); cosmo.set({'output':'tCl', 'Omega_Lambda':0.0,'w0_fld':-0.9,'foo_fld':1.0});cosmo.compute()"
I get the following message:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "classy.pyx", line 316, in classy.Class.compute (classy.c:5170)
classy.CosmoSevereError:
Error in Class: Class did not read input parameter(s): foo_fld
because the parameter foo_fld
is not being read. Please try this with your new parameter.
Cheers, Thomas
Yes, the point is probably that your python wrapper has not been recompiled since you have introduced your new parameter. The test proposed above by Thomas will show you whether the wrapper understands your new parameter or not. If not, most probably you just need to force the wrapper to recompile, which is done by just going to the CLASS directory and typing "make clean;make -j" (as Thomas wrote). It is likely that you either forgot the "make clean" or that you typed "make class" instead of "make" or "make all" ("make class" recompiles only the the C, not the wrapper).
Hi, Thanks for your suggestions. When I executed:
python -c "from classy import Class; cosmo=Class(); cosmo.set({'output':'tCl', 'Omega_Lambda':0.0,'w0_fld':-0.9,'myparameter_fld':1.0});cosmo.compute()"
in CLASS directory, there was no error or complain.
The problem is just in montepython which result in the error :
Cosmological Module Error: /|\ Something went wrong when calling CLASS /o\ Error in Class: Class did not read input parameter(s): myparameter_fld
only for my new parameter. I have defined my new parameter in the file 'cclassy.pxd' in the part 'cdef struct background:' (line 33) as 'double myparameter_fld' too. It seems that montepython can not realize the new parameter. Where should I define it in order to be recognized? Thanks
Hi
There is really no need to modify MontePython at all: the only thing MontePython does is to call the wrapper, and the wrapper generates the message above. Since you do not get the error when you call the wrapper directly, the most likely explanation is the one I mentioned before: you have two versions of CLASS installed, one modified and one unmodified and the default.conf
file points to the unmodified version. You should double-check that path['cosmo']
points to the modified CLASS folder.
And of course, you should check that you have put Omega_Lambda
to zero in your test parameter file..
Cheers, Thomas
After running 'make clean' and then 'make -j' in order to recompile the CLASS, another problem appeared in montepython. In running montepython , after the covariance matrix is made, the following problem appear: Segmentation fault (core dumped) which I never faced it, before recompiling the CLASS. I have studied the issue #82 too, however because I had no problem before recompiling, I am not sure that my problem is the same as this issue. do you think there is a problem with python? (an error with python appeared for the first time I faced this problem and in other running did not.) Thanks
Hi
I can almost guarantee you that it is not a problem with Python but with your modification. You should test your modification in detail first and then return to MontePython when you are confident that it is working properly. Valgrind can be helpful, good luck!
Cheers, Thomas
Hi @mahtaparsa
I think I am suffering a similar problem as the one you post here. Did you find a way to solve it?
Your help will be very useful!
Hi everybody, I have modified the CLASS for my cosmological model, with introducing some new parameters. Working in CLASS there is no problem with new parameters and I can plot the CMB temperature and matter power spectra for my model. However, there are problems in working with montepython, in which when I put my new parameters in the list of 'cosmo' parameters, in order to find the best fit of them, the following error would appear: Cosmological Module Error: /|\ Something went wrong when calling CLASS /o\ Error in Class: Class did not read input parameter(s): the name of my new parameters
It seems that montepython can not realize the new parameters. Should I introduce the new parameters for montepython separately? If it is the case, how can I do it? Or may be there is another problem with my code! Thanks for your suggestions.