zblz / naima

Derivation of non-thermal particle distributions through MCMC spectral fitting
http://naima.readthedocs.io
BSD 3-Clause "New" or "Revised" License
43 stars 54 forks source link

Does nor support indexing with running sampler #201

Closed Jongsu020509 closed 4 years ago

Jongsu020509 commented 4 years ago

When I run model fitting example in website,

helab@helab:~/Lee/Tex/exam_python/CTA$ python test_naima.py INFO: Finding Maximum Likelihood parameters through Nelder-Mead fitting... [naima.core] INFO: Initial parameters: [1.87859806e+32 3.00000000e+00 1.47712125e+00] [naima.core] INFO: Initial lnprob(p0): -175.747 [naima.core] INFO: New ML parameters : [1.38844453e+32 2.57175369e+00 1.68211459e+00] [naima.core] INFO: Maximum lnprob(p0): -18.019 [naima.core] Burning in the 32 walkers with 100 steps...

Progress of the run: 0 percent (0 of 100 steps) Traceback (most recent call last): File "test_naima.py", line 86, in prefit=True, File "/home/helab/anaconda2/lib/python2.7/site-packages/naima/core.py", line 561, in run_sampler sampler, pos = get_sampler(**kwargs) File "/home/helab/anaconda2/lib/python2.7/site-packages/naima/core.py", line 522, in get_sampler sampler, pos = _run_mcmc(sampler, p0, nburn) File "/home/helab/anaconda2/lib/python2.7/site-packages/naima/core.py", line 166, in _run_mcmc npars = out[0].shape[-1] TypeError: 'State' object does not support indexing

I got this message. How do I solve this error? @zblz

zblz commented 4 years ago

Hi! Is it possible that you are running Naima with version 3 of emcee? Unfortunately Naima only supports emcee 2 for the time being. Installing the latest version of Naima from PyPi should pull in the correct emcee version.

Jongsu020509 commented 4 years ago

Dear Zabalza,

Hi. Thanks for your reply! I used emcee 3.0.

But I solved my problem to edit one thing. I made parameter to a list type at line166. And then the code was run! Can I do that?

Thanks for making this library.

Best Regards, Jongsu

이종수(Jongsu Lee): PhD Student High-Energy Laboratory Department of Space Science & Geology Chungnam National University TEL(Phone): +82-10-4909-1503

2020년 5월 16일 (토) 오후 4:01, Víctor Zabalza notifications@github.com님이 작성:

Hi! Is it possible that you are running Naima with version 3 of emcee? Unfortunately Naima only supports emcee 2 for the time being. Installing the latest version of Naima from PyPi should pull in the correct emcee version.

El dv., 15 de maig 2020, 7:52, Jongsu020509 notifications@github.com va escriure:

helab@helab:~/Lee/Tex/exam_python/CTA$ python test_naima.py INFO: Finding Maximum Likelihood parameters through Nelder-Mead fitting... [naima.core] INFO: Initial parameters: [1.87859806e+32 3.00000000e+00 1.47712125e+00] [naima.core] INFO: Initial lnprob(p0): -175.747 [naima.core] INFO: New ML parameters : [1.38844453e+32 2.57175369e+00 1.68211459e+00] [naima.core] INFO: Maximum lnprob(p0): -18.019 [naima.core] Burning in the 32 walkers with 100 steps...

Progress of the run: 0 percent (0 of 100 steps) Traceback (most recent call last): File "test_naima.py", line 86, in prefit=True, File "/home/helab/anaconda2/lib/python2.7/site-packages/naima/core.py", line 561, in run_sampler sampler, pos = get_sampler(**kwargs) File "/home/helab/anaconda2/lib/python2.7/site-packages/naima/core.py", line 522, in get_sampler sampler, pos = _run_mcmc(sampler, p0, nburn) File "/home/helab/anaconda2/lib/python2.7/site-packages/naima/core.py", line 166, in _run_mcmc npars = out[0].shape[-1] TypeError: 'State' object does not support indexing

I got this message. How do I solve this error?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/zblz/naima/issues/201, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AAEMWAVYEUUVBWOU74R5POTRRTREPANCNFSM4NBJ6NJA

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zblz/naima/issues/201#issuecomment-629599727, or unsubscribe https://github.com/notifications/unsubscribe-auth/APS4AHUHFF26DAEZ256IEGTRRY23ZANCNFSM4NBJ6NJA .

zblz commented 4 years ago

In that case you should install emcee 2 (as naima's dependencies specify).