Open Jongsu020509 opened 10 months ago
Can you provide the full traceback of the error?
Hi,
Here is the full trackbase of the error:
Traceback (most recent call last):
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/multiprocessing/pool.py", line 48, in mapstar
return list(map(*args))
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/site-packages/emcee/ensemble.py", line 624, in call
return self.f(x, *self.args, **self.kwargs)
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/site-packages/naima/core.py", line 109, in lnprob
modelout = modelfunc(pars, data)
File "/Users/jongsulee/Work/python_code/CTA_New_CODE/GC_diffuse/NGC6397/test/SynIC_PL_Bsh_00.py", line 42, in ElectronSynIC
model = IC.flux(data, distance=dist).to(data["flux"].unit) +
SYN.flux(data, distance=dist).to(data["flux"].unit)
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/site-packages/naima/radiative.py", line 771, in flux
model = super().flux(photon_energy, distance=distance)
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/site-packages/naima/model_utils.py", line 63, in model
result = func(cls, energy, *args, **kwargs)
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/site-packages/naima/radiative.py", line 101, in flux
spec = self._spectrum(photon_energy)
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/site-packages/naima/radiative.py", line 748, in _spectrum
self._calc_specic(seed, outspecene).to("1/(s eV)")
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/site-packages/naima/radiative.py", line 705, in _calc_specic
self._gam, T.to("K").value, Eph
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/site-packages/naima/radiative.py", line 155, in _gam
return np.logspace(
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/site-packages/numpy/core/function_base.py", line 295, in logspace
y = linspace(start, stop, num=num, endpoint=endpoint, axis=axis)
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/site-packages/numpy/core/function_base.py", line 124, in linspace
raise ValueError("Number of samples, %s, must be non-negative." % num)
ValueError: Number of samples, -11, must be non-negative.
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File
"/Users/jongsulee/Work/python_code/CTA_New_CODE/GC_diffuse/NGC6397/test/SynIC_PL_Bsh_00.py",
line 72, in
sampler, pos = naima.run_sampler(
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/site-packages/naima/core.py", line 551, in run_sampler
sampler, pos = _run_mcmc(sampler, pos, nrun)
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/site-packages/naima/core.py", line 134, in _run_mcmc
for i, state in enumerate(
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/site-packages/emcee/ensemble.py", line 402, in sample
state, accepted = move.propose(model, state)
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/site-packages/emcee/moves/red_blue.py", line 93, in propose
new_log_probs, new_blobs = model.compute_log_prob_fn(q)
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/site-packages/emcee/ensemble.py", line 489, in compute_log_prob
results = list(map_func(self.log_prob_fn, p))
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/multiprocessing/pool.py", line 367, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/Users/jongsulee/miniforge3/envs/naima/lib/python3.10/multiprocessing/pool.py", line 774, in get
raise self._value
ValueError: Number of samples, -11, must be non-negative.
Sometimes, my code ends up completely successful. In the case of nwalker=10, and nrum=1000. nrun=100 succeeds relatively often.
Thanks for your reply.
Best Regards, Jongsu
2023년 8월 23일 (수) 오전 1:34, Víctor Zabalza @.***>님이 작성:
Can you provide the full traceback of the error?
— Reply to this email directly, view it on GitHub https://github.com/zblz/naima/issues/228#issuecomment-1688551863, or unsubscribe https://github.com/notifications/unsubscribe-auth/APS4AHTMFS3AM3TPUMQ2IL3XWTNQBANCNFSM6AAAAAA3XGX6RU . You are receiving this because you authored the thread.Message ID: @.***>
I hope this message finds you well.
I have developed a code using the Syn and IC model, utilizing X-ray and Gamma-ray data. The code structure is as follows:
def ElectronSynIC(pars, data): amplitude = pars[0] / u.eV alpha = pars[1] E0 = 1 u.TeV dist = 4.5 u.kpc Bemi_unit = pars[2] * u.uG Emax = 10*pars[3] u.TeV Emin = 10*pars[4] u.MeV
def lnprior(pars): logprob = ( naima.uniform_prior(pars[0], 0.0, np.inf)
if name == "main": p0 = np.array((1.e33, 3., 30, 1.0, 2.5)) labels = ["norm", "alpha", "Bsh", "Emax", "Emin"] sampler, pos = naima.run_sampler( data_table=[xray, vhe1, vhe2], p0=p0, labels=labels, model=ElectronSynIC, prior=lnprior, nwalkers=10, nburn=50, nrun=5000, threads=8, prefit=True, interactive=False )
While running the code, I encountered the following error:
ValueError: Number of samples, -22, must be non-negative.
In a previous inquiry, it was suggested that the issue might be related to Emin and Emax. However, based on my analysis, it seems that the prior ranges for Emin and Emax do not overlap. Could you please assist me in identifying the source of the problem? Is it related to the energy settings or could there be another underlying issue?
I greatly appreciate your expertise and assistance in resolving this matter. Your guidance would be immensely valuable to me.
Thank you for your time and consideration.