brinckmann / montepython_public

Public repository for the Monte Python Code
MIT License
92 stars 78 forks source link

A problem when using sdss lrgDR7 data in montepython #362

Closed satire16 closed 4 months ago

satire16 commented 5 months ago

Hello!Dear professor. I'am a student studying cosmology. Now I am working on a project which need to do MCMC analysis with the LSS data, such as the sdss IrgDR7. But i meet some problem when i use the sdss lrgDR7. When i input the command:

python MontePython.py run -p /home/xiapengbo/montepython_public-3.5/input/sdss_lrgDR7.param -o /home/xiapengbo/montepython_public-3.5/output/cotton4 -N 10000000 --update 50 --superupdate 20 -f 0.7 --conf /home/xiapengbo/montepython_public-3.5/my.conf

there will be a error that :

Traceback (most recent call last): File "/home/xiapengbo/montepython_public-3.5/montepython/MontePython.py", line 40, in sys.exit(run()) File "/home/xiapengbo/montepython_public-3.5/montepython/run.py", line 45, in run sampler.run(cosmo, data, command_line) File "/home/xiapengbo/montepython_public-3.5/montepython/sampler.py", line 46, in run mcmc.chain(cosmo, data, command_line) File "/home/xiapengbo/montepython_public-3.5/montepython/mcmc.py", line 474, in chain loglike = sampler.compute_lkl(cosmo, data) File "/home/xiapengbo/montepython_public-3.5/montepython/sampler.py", line 776, in compute_lkl value = likelihood.loglkl(cosmo, data) File "/home/xiapengbo/montepython_public-3.5/montepython/likelihood_class.py", line 2534, in loglkl fiducial = np.loadtxt('data/sdss_lrgDR7/sdss_lrgDR7_fiducialmodel.dat') File "/home/xiapengbo/anaconda3/lib/python3.9/site-packages/numpy/lib/npyio.py", line 1067, in loadtxt fh = np.lib._datasource.open(fname, 'rt', encoding=encoding) File "/home/xiapengbo/anaconda3/lib/python3.9/site-packages/numpy/lib/_datasource.py", line 193, in open return ds.open(path, mode, encoding=encoding, newline=newline) File "/home/xiapengbo/anaconda3/lib/python3.9/site-packages/numpy/lib/_datasource.py", line 533, in open raise IOError("%s not found." % path) OSError: data/sdss_lrgDR7/sdss_lrgDR7_fiducialmodel.dat not found.

it is quit stranger that in the data file in its likehood shows it should automatically create the fiducialmodel to accelerated calculation. But actually there will not be.

I am very confused and unable to solve this problem. I will be very appreciate if you can solve this problem in your busy time.

brinckmann commented 5 months ago

Hi,

I'm not sure why, but it seems it doesn't enter the correct if statement in the file montepython/likelihood_class.py on line 2515 (in the public version, yours might differ, but it is around this line:

            if self.create_fid == True:
                # Calculate relevant flat fiducial quantities

Under this if statement it creates the file that is missing, which it tries to load on the official version line 2541 (yours appears to be 2534) fiducial = np.loadtxt('data/sdss_lrgDR7/sdss_lrgDR7_fiducialmodel.dat')

The solution would be to understand why it doesn't enter this if statement and force it to if necessary.

Best, Thejs

satire16 commented 4 months ago

i don't know why it cannot enter the file. But i try to change the pass into the absulote pass in my computer and it can work. Thank you professor!

brinckmann commented 4 months ago

Great, thanks for reporting back!

Best, Thejs