ROOT Version (6.12/06):
Platform, compiler (Arch-Linux , python 3.6.5):
Hi guys, I having troubles running TH2F in PyROOT.
This is my code.
def plotRADEC(data, name):
from ROOT import TCanvas, TGraph, TH2F, TH2, TH1
from ROOT import gROOT, gSystem, Double
from array import array
import numpy as np
c1 = TCanvas('c1', '', 800, 600)
c1.SetBottomMargin( 0.15 )
c1.SetTopMargin( 0.05 )
c1.SetLeftMargin( 0.15 )
c1.SetRightMargin( 0.15 )
#gr = TGraph( len(data['dec']) - 1, data['dec'], data['ra'] )
nbins = len(data['dec'])
#px, py = Double(), Double()
px = array('f', data['dec'])
py = array('f', data['ra'])
gr = TH2F('gr', '', nbins , np.min(data['dec']), np.max(data['dec']), nbins, np.min(data['ra']), np.max(data['ra']) )
for i in range(nbins):
#print(i, data['dec'][i], data['ra'][i] )
#px = data['dec'][i]
#py = data['ra'][i]
gr.Fill(px[i], py[i])
gr.Draw('aitoff')
c1.Print(name)
name is a string, and data is a python dictionary where data[‘ra’] and data[‘dec’] are arrays.
This is the full output of the problem.
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
Thread 2 (Thread 0x7f6ffe870700 (LWP 24514)):
#0 0x00007f702185344a in pthread_cond_timedwait
GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1 0x00007f70210458c2 in PyEval_RestoreThread () from /usr/lib/libpython3.6m.so.1.0
#2 0x00007f702101c31d in ?? () from /usr/lib/libpython3.6m.so.1.0
#3 0x00007f702108a645 in _PyCFunction_FastCallDict () from /usr/lib/libpython3.6m.so.1.0
#4 0x00007f70210579fb in ?? () from /usr/lib/libpython3.6m.so.1.0
#5 0x00007f7021045fba in _PyEval_EvalFrameDefault () from /usr/lib/libpython3.6m.so.1.0
#6 0x00007f7021057fa8 in PyEval_EvalCodeEx () from /usr/lib/libpython3.6m.so.1.0
#7 0x00007f70210e5136 in ?? () from /usr/lib/libpython3.6m.so.1.0
#8 0x00007f702109a39b in PyObject_Call () from /usr/lib/libpython3.6m.so.1.0
#9 0x00007f70210476f3 in _PyEval_EvalFrameDefault () from /usr/lib/libpython3.6m.so.1.0
#10 0x00007f702105753b in ?? () from /usr/lib/libpython3.6m.so.1.0
#11 0x00007f7021057abe in ?? () from /usr/lib/libpython3.6m.so.1.0
#12 0x00007f7021045fba in _PyEval_EvalFrameDefault () from /usr/lib/libpython3.6m.so.1.0
#13 0x00007f702105753b in ?? () from /usr/lib/libpython3.6m.so.1.0
#14 0x00007f7021057abe in ?? () from /usr/lib/libpython3.6m.so.1.0
#15 0x00007f7021045fba in _PyEval_EvalFrameDefault () from /usr/lib/libpython3.6m.so.1.0
#16 0x00007f702105704b in _PyFunction_FastCallDict () from /usr/lib/libpython3.6m.so.1.0
#17 0x00007f702109956f in _PyObject_FastCallDict () from /usr/lib/libpython3.6m.so.1.0
#18 0x00007f702109a2b3 in _PyObject_Call_Prepend () from /usr/lib/libpython3.6m.so.1.0
#19 0x00007f702109a39b in PyObject_Call () from /usr/lib/libpython3.6m.so.1.0
#20 0x00007f702110f586 in ?? () from /usr/lib/libpython3.6m.so.1.0
#21 0x00007f702184d0bc in start_thread () from /usr/lib/libpthread.so.0
#22 0x00007f70215822ff in clone () from /usr/lib/libc.so.6
Thread 1 (Thread 0x7f7021c4a540 (LWP 24490)):
#0 0x00007f702154f582 in waitpid () from /usr/lib/libc.so.6
#1 0x00007f70214cd21f in do_system () from /usr/lib/libc.so.6
#2 0x00007f700ab71a24 in TUnixSystem::StackTrace() () from /usr/lib/root/libCore.so
#3 0x00007f700ab7425e in TUnixSystem::DispatchSignals(ESignals) () from /usr/lib/root/libCore.so
#4 <signal handler called>
#5 0x00007f6ffd2b09d6 in TH2F::AddBinContent(int) () from /usr/lib/root/libHist.so
#6 0x00007f6ffd2a8495 in TH2::Fill(double, double) () from /usr/lib/root/libHist.so
#7 0x00007f7021aac053 in ?? ()
#8 0x00005591a5036a40 in ?? ()
#9 0x00007ffd421ec594 in ?? ()
#10 0x00007ffd421ec594 in ?? ()
#11 0x00007ffd421ec4c0 in ?? ()
#12 0x0000000200000000 in ?? ()
#13 0x00005591a5034ce0 in ?? ()
#14 0x00007ffd421ec580 in ?? ()
#15 0x00007f700b73d2c3 in FastCall(long, void*, void*, void*) () from /usr/lib/root/libPyROOT.so
===========================================================
The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum.
Only if you are really convinced it is a bug in ROOT then please submit a
report at http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5 0x00007f6ffd2b09d6 in TH2F::AddBinContent(int) () from /usr/lib/root/libHist.so
#6 0x00007f6ffd2a8495 in TH2::Fill(double, double) () from /usr/lib/root/libHist.so
#7 0x00007f7021aac053 in ?? ()
#8 0x00005591a5036a40 in ?? ()
#9 0x00007ffd421ec594 in ?? ()
#10 0x00007ffd421ec594 in ?? ()
#11 0x00007ffd421ec4c0 in ?? ()
#12 0x0000000200000000 in ?? ()
#13 0x00005591a5034ce0 in ?? ()
#14 0x00007ffd421ec580 in ?? ()
#15 0x00007f700b73d2c3 in FastCall(long, void*, void*, void*) () from /usr/lib/root/libPyROOT.so
===========================================================
Traceback (most recent call last):
File "readcatalog.py", line 139, in <module>
main()
File "readcatalog.py", line 136, in main
plotRADEC(data, args.outname)
File "readcatalog.py", line 99, in plotRADEC
gr.Fill(px[i], py[i])
TypeError: none of the 5 overloaded methods succeeded. Full details:
int TH2::Fill(const char* namex, const char* namey, double w) =>
takes at least 3 arguments (2 given)
int TH2::Fill(double x, double y) =>
problem in C++; program state has been reset
int TH2::Fill(double x, const char* namey, double w) =>
takes at least 3 arguments (2 given)
int TH2::Fill(const char* namex, double y, double w) =>
takes at least 3 arguments (2 given)
int TH2::Fill(double x, double y, double w) =>
takes at least 3 arguments (2 given)
Any ideas about how to handle it?