gammapy/enrico

Problem with enrico_plot_lc

Closed this issue · 1 comments

Hi,

I am using the most recent version of enrico and when use enrico_plot_lc I get the following error

[LightCurve]: Reading files produced by enrico
Saw kwargs [u'ls', u'linestyle'] which are all aliases for u'linestyle'. Kept value from u'linestyle'
/home/enrico/enrico/plotting.py:343: RuntimeWarning: divide by zero encountered in log10
optimal_markersize = (0.5+4./(1.+np.log10(len(y))))
/home/enrico/enrico/plotting.py:344: RuntimeWarning: divide by zero encountered in log10
optimal_errorlinewidth = (0.2+2./(1.+4.*np.log10(len(y))))
Traceback (most recent call last):
File "/home/enrico/bin/enrico_plot_lc", line 30, in
lcobject.PlotLC()
File "/home/enrico/enrico/lightcurve.py", line 216, in PlotLC
self._PlotLC()
File "/home/enrico/enrico/lightcurve.py", line 443, in _PlotLC
uplimIndex[~uplimIndex],bblocks=True)
File "/home/enrico/enrico/plotting.py", line 386, in plot_errorbar_withuls
edges = bayesian_blocks(x,y,yerr,fitness='measures',p0=0.5)
File "/home/enrico/enrico/extern/astropy_bayesian_blocks.py", line 154, in bayesian_blocks
return fitfunc.fit(t, x, sigma)
File "/home/enrico/enrico/extern/astropy_bayesian_blocks.py", line 334, in fit
block_length = t[-1] - edges
IndexError: index -1 is out of bounds for axis 0 with size 0

If I fix the photon index in the config file this error disappears.

Please, can someone help me to understand what is the problem?

Thanks

There should be a check when we call the bayesian block code to check the number of data points. Could it be perhaps that the source is not detected or you have only upper limits when the index is left free?

Perhaps changing in enrico/plotting:381 from

if bblocks and len(x[uplim])>2:
to

if bblocks and len(x[~uplim])>2:

does the trick. Adding a pull request (untested) to fix this.