Adding utc date to tgraph

Hello,
back with another question, does anybody know how to add utc dates to a TGraph?
I found that utctime = ROOT.TDatetime() should work but I get the error:

AttributeError: type object ‘ROOT’ has no attribute ‘TDatime’

the script looks something like:

#!/usr/bin/env python
import sys
from array import array
from ROOT import *
import scipy

gROOT.ProcessLine(
"struct tdata_t {\
   Char_t	   utcTime[20];\
};" );


file = TFile("../output/tData.root")
tree=file.Get("mytree")

tData = tData_t()

tree.SetBranchAddress("utcTime",AddressOf(tData,"utcTime"))

nev = tree.GetEntries()

for iev in range(0,nev):
	if(iev<10): print "first 10 entries...", iev
        
	tree.GetEntry(iev)
	
	utctime_=tData.utcTime
        
	yy = utctime_[0:4]
	mm = utctime_[5:7]
	dd = utctime_[8:10]
	hh = utctime_[11:13]
	mi = utctime_[14:16]
	ss = utctime_[17:19]
        

        utctime_ = ROOT.TDatime(yy,mm,dd,hh,mi,ss)
....

Thanks for your help,
lore

Hi,

once you did “from ROOT import *” you should use TDateTime, not ROOT.TDateTime. Within the python module ROOT, there’s a (little used) C++ namespace ROOT, hence the error indicates that it does not contain TDateTime, rather than stating that ROOT isn’t a known name.

Cheers,
Wim