BellaNasirudin / py21cmmc_fg

A foreground and instrumental plugin for py21cmmc
MIT License
1 stars 4 forks source link

Issues with numerical covariance #25

Closed BellaNasirudin closed 5 years ago

BellaNasirudin commented 5 years ago

From the newest commit b5add1c313a9b2331186d2ae6f80ccb2381d253f , with the parameters completely unchanged, a bug caused this error:

(21cmmc) bella@bella-System-Product-Name:~/Projects/Parameter_estimation_21cmmc/Codes/py21cmmc_fg/devel/test_series$ python gridded_noise_psfg.py /home/bella/powerbox/powerbox/dft.py:51: UserWarning: You do not have pyFFTW installed. Installing it should give some speed increase. warnings.warn("You do not have pyFFTW installed. Installing it should give some speed increase.") Traceback (most recent call last): File "gridded_noise_psfg.py", line 39, in continue_sampling=False # Whether to contine sampling from previous run up to sampleIterations. File "/home/bella/Projects/Parameter_estimation_21cmmc/Codes/py21cmmc_fg/devel/test_series/base_definitions.py", line 103, in run_mcmc **kwargs File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/py21cmmc-0.1.0-py3.6-linux-x86_64.egg/py21cmmc/mcmc/mcmc.py", line 93, in run_mcmc chain = build_computation_chain(core_modules, likelihood_modules, params) File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/py21cmmc-0.1.0-py3.6-linux-x86_64.egg/py21cmmc/mcmc/mcmc.py", line 37, in build_computation_chain chain.setup() File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/py21cmmc-0.1.0-py3.6-linux-x86_64.egg/py21cmmc/mcmc/cosmoHammer/LikelihoodComputationChain.py", line 82, in setup cModule.setup() File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/py21cmmc_fg-0.1.0-py3.6-linux-x86_64.egg/py21cmmc_fg/likelihood.py", line 307, in setup self.n_uv = self._instr_core.n_cells File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/py21cmmc_fg-0.1.0-py3.6-linux-x86_64.egg/py21cmmc_fg/likelihood.py", line 428, in _instr_core for m in self._cores: AttributeError: 'CustomLikelihood' object has no attribute '_cores'

I have fixed this by changing it back to self.LikelihoodComputationChain.getCoreModules() in 261e4a8ee5df84f37c190ffc428f206620977f2c since self._cores doesn't exist. Feel free to correct this if I'm doing something stupid.

It then runs into a different error when it tries to find the numerical covariance:

Traceback (most recent call last): File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, kwds)) File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/multiprocessing/pool.py", line 44, in mapstar return list(map(args)) File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/emcee/ensemble.py", line 519, in call return self.f(x, self.args, self.kwargs) File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/cosmoHammer/LikelihoodComputationChain.py", line 103, in call likelihood = self.computeLikelihoods(ctx) File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/cosmoHammer/LikelihoodComputationChain.py", line 144, in computeLikelihoods likelihood += self.invokeLikelihoodModule(lModule, ctx) File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/py21cmmc-0.1.0-py3.6-linux-x86_64.egg/py21cmmc/mcmc/cosmoHammer/LikelihoodComputationChain.py", line 62, in invokeLikelihoodModule return module.computeLikelihood(model) File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/py21cmmc_fg-0.1.0-py3.6-linux-x86_64.egg/py21cmmc_fg/likelihood.py", line 411, in computeLikelihood total_cov = [x+y for x,y in zip(self.noise['covariance'], sig_cov)] TypeError: zip argument #1 must support iteration """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "gridded_noise_psfg.py", line 39, in continue_sampling=False # Whether to contine sampling from previous run up to sampleIterations. File "/home/bella/Projects/Parameter_estimation_21cmmc/Codes/py21cmmc_fg/devel/test_series/base_definitions.py", line 103, in run_mcmc **kwargs File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/py21cmmc-0.1.0-py3.6-linux-x86_64.egg/py21cmmc/mcmc/mcmc.py", line 105, in run_mcmc sampler.startSampling() File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/py21cmmc-0.1.0-py3.6-linux-x86_64.egg/py21cmmc/mcmc/cosmoHammer/CosmoHammerSampler.py", line 98, in startSampling self.sample(pos, prob, rstate, datas) File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/py21cmmc-0.1.0-py3.6-linux-x86_64.egg/py21cmmc/mcmc/cosmoHammer/CosmoHammerSampler.py", line 192, in sample return self._sample(burninPos, burninProb, burninRstate, datas) File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/py21cmmc-0.1.0-py3.6-linux-x86_64.egg/py21cmmc/mcmc/cosmoHammer/CosmoHammerSampler.py", line 165, in _sample lnprob0=prob, rstate0=rstate, blobs0=datas File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/emcee/ensemble.py", line 198, in sample lnprob, blobs = self._get_lnprob(p) File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/emcee/ensemble.py", line 382, in _get_lnprob results = list(M(self.lnprobfn, [p[i] for i in range(len(p))])) File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/site-packages/emcee/interruptible_pool.py", line 94, in map return r.get(self.wait_timeout) File "/home/bella/anaconda2/envs/21cmmc/lib/python3.6/multiprocessing/pool.py", line 644, in get raise self._value TypeError: zip argument #1 must support iteration

I am ignoring this for now by setting use_analytical_noise=True since I want to use the analytical version anyway.

steven-murray commented 5 years ago

The first error is due to needing to update 21CMMC, sorry should have mentioned that! Not sure for the second error... will investigate.

steven-murray commented 5 years ago

This should be fixed in 922bdbcbe65138c44538bab2cf30a833e31eca41. Let me know if not!