コード例 #1
0
def configureProfile(profile,i,minY,maxY,drawOption,data,log,textSize=25):
	profile.SetMarkerColor(MarkerColors[i])
	profile.SetMarkerStyle(MarkerStyles[i])
	profile.SetMarkerSize(MarkerSizes[i])
	profile.SetLineColor(MarkerColors[i])
	if drawOption!='P': profile.SetMarkerSize(0.0)
	if drawOption=='E3':
		#profile.SetFillStyle(3001)
		profile.SetFillColor(MarkerColors[i])
	if not i:
		profile.GetXaxis().SetLabelSize(textSize)
		profile.GetXaxis().SetTitleSize(textSize)
		profile.GetYaxis().SetLabelSize(textSize)
		profile.GetYaxis().SetTitleSize(textSize)
		profile.SetMinimum(minY)
		profile.SetMaximum(maxY)
		profile.GetXaxis().SetTitle(data['plotConfig']['xLabel'])
		profile.GetYaxis().SetTitle(data['plotConfig']['yLabel'])
	if data['xUnit'] == 'time':
		profile.GetXaxis().SetTimeDisplay(1)
		profile.GetXaxis().SetTimeFormat(data['plotConfig']['xFormat'])
		dh = TDatime()
		dh.Set(int(data['plotConfig']['xOffset']), False)
		profile.GetXaxis().SetTimeOffset(dh.Convert(False))
		profile.GetXaxis().SetNdivisions(507)
	else:
		profile.GetXaxis().SetTimeDisplay(0)
	return profile
コード例 #2
0
def makeTime():
    datime=TDatime()
    return '%d/%d/%d %.2d:%.2d:%.2d'%(datime.GetDay(),
             datime.GetMonth(),
             datime.GetYear(),
             datime.GetHour(),
             datime.GetMinute(),
             datime.GetSecond())
コード例 #3
0
 def __init__(self, settings=None):
     print 'Starting Histogram Saver'
     self.settings = settings
     self.run = array(self.settings.runInfo['run'], 'I')
     self.eventNumber = array(int(0), 'I')
     self.plotPath = '.'
     self.plotRootPath = './root/'
     self.plotPdfPath = './pdf/'
     self.paveTextOptions = {}
     self.dateTime = TDatime()
     self.paveText = TPaveText(0.07, 0, 0.22, 0.10, 'NDC')
     self.UpdatePaveText()
     self.verb = self.settings.runInfo['verbose']
     self.optStat1D = 'nemr'
     self.optStat2D = 'ne'
     self.DefaultPlotStyle()
コード例 #4
0
class HistogramSaver:
    def __init__(self, settings=None):
        print 'Starting Histogram Saver'
        self.settings = settings
        self.run = array(self.settings.runInfo['run'], 'I')
        self.eventNumber = array(int(0), 'I')
        self.plotPath = '.'
        self.plotRootPath = './root/'
        self.plotPdfPath = './pdf/'
        self.paveTextOptions = {}
        self.dateTime = TDatime()
        self.paveText = TPaveText(0.07, 0, 0.22, 0.10, 'NDC')
        self.UpdatePaveText()
        self.verb = self.settings.runInfo['verbose']
        self.optStat1D = 'nemr'
        self.optStat2D = 'ne'
        self.DefaultPlotStyle()

    def DefaultPlotStyle(self):
        gStyle.SetPalette(55)  # 55 is kRainBow. 53 is kDarkBodyRadiator
        gStyle.SetOptStat(self.optStat1D)
        gStyle.SetOptFit(11111)
        gStyle.SetStatH(0.12)
        gStyle.SetStatW(0.15)
        gStyle.SetPadBottomMargin(0.15)
        gStyle.SetPadTopMargin(0.15)

    def SetPath(self, path='.'):
        self.plotPath = self.RemoveExtraBackSlashes(path, 2)
        self.plotRootPath = self.RemoveExtraBackSlashes(path + '/root/', 3)
        self.plotPdfPath = self.RemoveExtraBackSlashes(path + '/pdf/', 3)
        self.settings.CheckDirExistence(self.plotPath, True)
        self.settings.CheckDirExistence(self.plotRootPath, True)
        self.settings.CheckDirExistence(self.plotPdfPath, True)

    def RemoveExtraBackSlashes(self, string, times=1):
        if times == 0:
            return string
        string = string.replace('//', '/')
        return self.RemoveExtraBackSlashes(string, times - 1)

    def UpdatePaveText(self):
        self.paveText.Clear()
        self.paveText.SetTextSize(0.025)
        self.paveTextOptions['svn'] = 'Rev: ' + self.settings.version
        self.paveTextOptions['run'] = 'Run ' + str(self.run)
        self.paveTextOptions['nEvents'] = 'with ' + str(
            self.settings.runInfo['nEvents']) + 'Events'
        self.paveTextOptions['DateTime'] = self.dateTime.AsSQLString()
        self.paveText.AddText(self.paveTextOptions['svn'])
        self.paveText.AddText(self.paveTextOptions['run'])
        self.paveText.AddText(self.paveTextOptions['nEvents'])
        self.paveText.AddText(self.paveTextOptions['DateTime'])
        self.paveText.SetBorderSize(0)
        self.paveText.SetFillColor(0)
コード例 #5
0
ファイル: generalplot.py プロジェクト: lopezzot/MMIntegration
def createplot(file, filename):

    times = [x.split(' 	 ')[0] for x in open(file, "r").readlines()]
    if len(times) == 1:
        print "Exception -----> Only one data in " + str(filename) + ".dat \n"
        return None
    if not times:
        print "Exception -----> File empty: " + str(filename) + ".dat \n"
        return None

    times = [x.replace(':', ' ') for x in times]
    times = [x.replace('/', ' ') for x in times]
    times = [x.replace('_', ' ') for x in times]
    times = [dt.strptime(x, '%m %d %Y %H %M %S') for x in times]

    starttime = times[0]
    dates = [starttime]

    times = [int((x - starttime).total_seconds()) for x in times]

    values = [float(x.split(' 	 ')[1]) for x in open(file, "r").readlines()]

    newtimes = range(times[len(times) - 1])
    newvalues = [None] * len(newtimes)

    for counter, value in enumerate(newvalues):
        if counter in times:
            newvalues[counter] = values[times.index(counter)]
        else:
            newvalues[counter] = newvalues[counter - 1]

    for counter in range(len(newtimes) - 1):
        dates.append(dates[counter] + td(seconds=1))

    rootdates = [
        TDatime(x.year, x.month, x.day, x.hour, x.minute, x.second)
        for x in dates
    ]
    meancurrent = np.mean(newvalues)
    spikecounter, filename, spikedates, spikeseconds, spikenames = search.findspikes_50na(
        newvalues, meancurrent, rootdates, newtimes, filename)
    print spikecounter
    write_rootdategraph(rootdates, newvalues, filename, "time (s)",
                        filename[0])

    return None
コード例 #6
0
 last = ibeam.IOVlast
 if option.Time:
     atime = ibeam.IOVBeginTime
     first = time.mktime(
         time.strptime(
             atime.split()[0] + " " + atime.split()[1] +
             " " + atime.split()[2],
             "%Y.%m.%d %H:%M:%S %Z"))
     atime = ibeam.IOVEndTime
     last = time.mktime(
         time.strptime(
             atime.split()[0] + " " + atime.split()[1] +
             " " + atime.split()[2],
             "%Y.%m.%d %H:%M:%S %Z"))
     da_first = TDatime(
         time.strftime(
             '%Y-%m-%d %H:%M:%S',
             time.localtime(first - time.timezone)))
     da_last = TDatime(
         time.strftime('%Y-%m-%d %H:%M:%S',
                       time.localtime(last -
                                      time.timezone)))
     if ipoint == 0:
         ## print local time
         da_first.Print()
         ## print gmt time
         print("GMT = " + str(
             time.strftime(
                 '%Y-%m-%d %H:%M:%S',
                 time.gmtime(first - time.timezone))))
         reftime = first
         ptm = time.localtime(reftime)
コード例 #7
0
numberOfNewDefects = np.zeros([3,9,12,56], dtype=np.uint32)
numberOfRefDefects = np.zeros([3,9,12,56], dtype=np.uint32)
numberOfNPtGainDefects = np.zeros([3,9,12,56], dtype=np.uint32)
numberOfNoiseOccupancyDefects = np.zeros([3,9,12,56], dtype=np.uint32)
numberOfNoisyStripsMon = np.zeros([3,9,12,56], dtype=np.uint32)
numberOfNoisyStripsMonOnly = np.zeros([3,9,12,56], dtype=np.uint32)
channelID = np.zeros([3,9,12,56], dtype=np.uint32)
noise_occup = np.zeros([3,9,12,56], dtype=np.float32)
eff = np.zeros([3,9,3], dtype=np.float32)
n_err_link = np.zeros([3,9,3], dtype=np.uint32)
noisy_strips_measured =  np.zeros([1], dtype=np.bool)
noise_occup_measured =  np.zeros([1], dtype=np.bool)
eff_measured =  np.zeros([1], dtype=np.bool)
n_err_link_measured =  np.zeros([1], dtype=np.bool)

start_time = TDatime()
end_time = TDatime()
start = np.zeros([1], dtype=np.uint32)
end = np.zeros([1], dtype=np.uint32)
duration = np.zeros([1], dtype=np.uint32)

data = bytearray(21) # all bytes of char_array are zeroed by default here (all b'\x00')

# create the branches and assign the fill-variables to them
t.Branch('Run', run, 'Run[1]/i')
t.Branch('Start', start, 'Start[1]/i')
t.Branch('End', end, 'End[1]/i')
t.Branch('Duration', duration, 'Duration[1]/i')
t.Branch('Good', good, 'Good[1]/O')
t.Branch('NumberOfDefects', numberOfDefects, 'NumberOfDefects[3][9][12][56]/i')
t.Branch('NumberOfNewDefects', numberOfNewDefects, 'NumberOfNewDefects[3][9][12][56]/i')
コード例 #8
0
def createplot(giffile, file, filename, folder):
	'''create graph of current of voltage, find spikes and linearity plots from GIF'''
	if "D" in filename:
		return None, None, None, None, None, None, None, None, None, None
	layer = filename[5:7] #get layer
	rootdirectory = directories[layer] #set root file directory

	sectorforarea = filename[8:9]
	chambertype = folder[0:3] #SM1 or SM2 LM1 or LM2

	#to be checked
	areasSM1 = {"1":(30.0+52.)*(45.2/4.), "2":(52.+70.2)*(43.5/4.), "3":(70.2+84.2)*(43.5/4.), "4":(84.2+104.)*(43.5/4.), "5":(104.+114.9)*(43.5/4.)}
	areasSM2 = {"6":(130.3+117.1)*(45.7/4.), "7":(150.5+130.3)*(43.6/4.), "8":(166.4+150.5)*(45.6/4.)}
	areasLM2 = {"6":(189.2+194.482)*(47.46/4.), "7":(194.482+200.1)*(46.08/4.), "8":(200.1+201.4)*(46.8/4.)} 
	areasLM1 = {"1":(48.8+85.)*(45.3/4.), "2":(85.+114.8)*(45.3/4.), "3":(114.8+137.7)*(43.5/4.), "4":(137.7+170.0)*(43.5/4.), "5":(170.0+187.8)*(43.5/4.)}

	if chambertype == "SM1":
		areas=areasSM1
	elif chambertype == "SM2":
		areas=areasSM2
	elif chambertype == "LM1":
		areas=areasSM1
	elif chambertype == "LM2":
		areas=areasSM2
	else:
		print "areas not found"
	area = areas[sectorforarea]

	times = [x.split(' 	 ')[0] for x in open(file,"r").readlines()]
	if len(times) == 1:
		print "Exception -----> Only one data in "+str(filename)+".dat \n" #handle exception of empty files (should not be the case after daq fixing)
		return None, None, None, None, None, None, None, None, None
	if not times:
		print "Exception -----> File empty: "+str(filename)+".dat \n"
		return None, None, None, None, None, None, None, None, None

	times = [x.replace(':',' ') for x in times]
	times = [x.replace('/',' ') for x in times]
	times = [x.replace('_',' ') for x in times]
	times = [dt.strptime(x, '%m %d %Y %H %M %S') for x in times]

	starttime = times[0]
	dates = [starttime]

	times = [int((x-starttime).total_seconds()) for x in times]

	values = [float(x.split(' 	 ')[1]) for x in open(file,"r").readlines()]

	newtimes = range(times[len(times)-1])
	newvalues = [None]*len(newtimes)

	for counter, value in enumerate(newvalues):
		if counter in times:
			newvalues[counter] = values[times.index(counter)]
		else:
			newvalues[counter] = newvalues[counter-1]

	for counter in range(len(newtimes)-1):
		dates.append(dates[counter]+td(seconds=1))

	rootdates = [TDatime(x.year, x.month, x.day, x.hour, x.minute, x.second) for x in dates]
	#end of creating vectors for times, dates, values (current or voltage)

	sectorscurrent = None #default values
	sectorsvoltage = None
	meancurrent = None
	nospike_meancurrent = None #to have current not affected by spikes
	meanvoltage = None
	notrips_meanvoltage = None

	duration = len(newtimes) #total seconds from start to stop

	#data from gif file (for attenuation)------------------------
	atten = [x.split(' 	 ') for x in open(giffile,"r").readlines()[1:]] #read attenutation factor exept first line (header)
	#atten = [x for x in atten if len(x) == 11] #used before change in daq
	atten_times = [x[0] for x in atten]
	atten_values = [float(x[1]) for x in atten]

	atten_times = [x.replace(':',' ') for x in atten_times]
	atten_times = [x.replace('/',' ') for x in atten_times]
	atten_times = [x.replace('_',' ') for x in atten_times]
	atten_times = [dt.strptime(x, '%m %d %Y %H %M %S') for x in atten_times]

	atten_starttime = atten_times[0]
	atten_dates = [atten_starttime]

	atten_times = [int((x-atten_starttime).total_seconds()) for x in atten_times]

	atten_newtimes = range(atten_times[len(atten_times)-1])
	atten_newvalues = [None]*len(atten_newtimes)

	for atten_counter, atten_value in enumerate(atten_newvalues):
		if atten_counter in atten_times:
			atten_newvalues[atten_counter] = atten_values[atten_times.index(atten_counter)]
		else:
			atten_newvalues[atten_counter] = atten_newvalues[atten_counter-1]

	for counter in range(len(atten_newtimes)-1):
		atten_dates.append(atten_dates[counter]+td(seconds=1)) #end of creating arrays atten values and times

	source = [x.split(' 	 ') for x in open(sourcefile,"r").readlines()[1:]] #read attenutation factor exept first line (header)
	#atten = [x for x in atten if len(x) == 11] #used before change in daq
	source_times = [x[0] for x in source]
	source_values = [float(x[1]) for x in source] #0.0 off 1.0 on

	source_times = [x.replace(':',' ') for x in source_times]
	source_times = [x.replace('/',' ') for x in source_times]
	source_times = [x.replace('_',' ') for x in source_times]

	source_times = [dt.strptime(x, '%m %d %Y %H %M %S') for x in source_times]

	source_starttime = source_times[0]
	source_dates = [source_starttime]

	source_times = [int((x-source_starttime).total_seconds()) for x in source_times]

	source_newtimes = range(source_times[len(source_times)-1])
	source_newvalues = [None]*len(source_newtimes)

	for source_counter, source_value in enumerate(source_newvalues):
		if source_counter in source_times:
			source_newvalues[source_counter] = source_values[source_times.index(source_counter)]
		else:
			source_newvalues[source_counter] = source_newvalues[source_counter-1]

	for counter in range(len(source_newtimes)-1):
		source_dates.append(source_dates[counter]+td(seconds=1)) #end of creating arrays source values and times

	#now important to match starting time of source file and atten file
	if "i" in filename and "D" not in filename:

		if source_dates[10] in atten_dates:
			syncindex = atten_dates.index(source_dates[10])
			source_dates = source_dates[10:]
		else:
			syncindex = atten_dates.index(source_dates[50])
			source_dates = source_dates[50:]
		atten_dates = atten_dates[syncindex:]
		if len(atten_dates) > len(source_dates):
			atten_dates = atten_dates[0:len(source_dates)]
			atten_newvalues = atten_newvalues[0:len(source_newvalues)] #attenuation values sync to i values
		elif len(atten_dates) < len(source_dates):
			source_dates = source_dates[0:len(atten_dates)]
			source_newvalues = source_newvalues[0:len(atten_newvalues)] #syn complete

		#for counter in range(0,50):
		#	print source_dates[counter],source_newvalues[counter],atten_dates[counter],atten_newvalues[counter]

	#part added on 7/10/2019 to sync also the end of data from source.dat and effectiveattenuation.dat	
	if len(atten_newvalues)>len(source_newvalues):
		atten_newvalues = atten_newvalues[:len(source_newvalues)]
	else:
		source_newvalues = source_newvalues[:len(atten_newvalues)]

	for counter, atten_newvalue in enumerate(atten_newvalues):
		if counter < len(source_newvalues):
			if source_newvalues[counter] == 0.0:
				atten_newvalues[counter] = 0.0  #put attenuation to 0 il source is off, i will later remove zeros
		'''
		else:                                   #else assing 0 to all remaining current values if source was off for the last minutes
			if source_newvalues[len(source_newvalues)-1] == 0.0:
				for x in atten_newvalues[len(source_newvalues)-1::len(atten_newvalues)-1]:
					x = 0.0
		'''
	#completed date array and attenuation array from GIF
	#now important to match starting time with data from chamber
	#not done for drift

	if "i" in filename and "D" not in filename:

		if dates[10] in atten_dates:
			syncindex = atten_dates.index(dates[10])
			dates = dates[10:]
		else:
			syncindex = atten_dates.index(dates[100]) #mettere 100 e provare!
			dates = dates[100:]
		atten_dates = atten_dates[syncindex:]
		if len(atten_dates) > len(dates):
			atten_dates = atten_dates[0:len(dates)]
			atten_newvalues = atten_newvalues[0:len(newvalues)] #attenuation values sync to i values
		elif len(atten_dates) < len(dates):
			dates = dates[0:len(atten_dates)]
			newvalues = newvalues[0:len(atten_newvalues)] #syn complete!

		#if want to check sync, first 50 seconds
		#for counter in range(0,50):
		#	print dates[counter],newvalues[counter],atten_dates[counter],atten_newvalues[counter]

	#end data from gif file--------------------------------------

		new_rootdates = [TDatime(x.year, x.month, x.day, x.hour, x.minute, x.second) for x in dates] #rootdates with updated dates


	#start analysis, i'm in "i" not drift files
		sectorscurrent = filename[5:9] #sector name
		meancurrent = np.mean(newvalues) #mean of current value

		#Identify drops
		valuesdeltas = np.diff(newvalues)
		valuesdeltas = [0]+valuesdeltas #differences in currents of voltages

		#remove spikes in current files
		copynewvalues = copy.copy(newvalues) #need to copy it to pass to function below
		nospike_newvalues = search.removespikes_atgif(valuesdeltas, copynewvalues, atten_newvalues) #remove spikes when source on at gif current files
		#for i in range(3):
		#	nospike_newvalues = search.removespikes_atgif([0]+np.diff(nospike_newvalues), nospike_newvalues, atten_values) #two times to actually remove spikes
		#nospike_newvalues = search.removespikes_atgif([0]+np.diff(nospike_newvalues), nospike_newvalues, atten_values) #two times to actually remove spikes
		#nospike_newvalues = search.removespikes_atgif([0]+np.diff(nospike_newvalues), nospike_newvalues, atten_values) #two times to actually remove spikes
		#nospike_newvalues = search.removespikes_atgif([0]+np.diff(nospike_newvalues), nospike_newvalues, atten_values) #two times to actually remove spikes
		nospike_meancurrent = np.mean(nospike_newvalues) #used to have real baseline of the current under fixed flux

		setattenvalues = set(atten_newvalues)
		setattenvalues = [x for x in setattenvalues if float(x) != 0.] #remove 0
		setattenvalues.sort(reverse=True) #from min to max
		setmeancurrents = []
		normalizedsetmeancurrents = []

		#print len(newvalues), len(atten_newvalues)
		currentatzero = [x for counter, x in enumerate(newvalues[0:len(atten_newvalues)]) if atten_newvalues[counter] == 0.] #current when source is off
		currentatzero = np.mean(currentatzero) #current mean when source is off

		for setattenuation in setattenvalues: #using nospike_newvalues here to not count spikes
			startindex = atten_newvalues.index(setattenuation) #first second at a given attenuation
			lastindex = len(atten_newvalues)-atten_newvalues[::-1].index(setattenuation)-1 #last second at a given attenuation
			middle = (lastindex-startindex)/2
			found = [x for x in nospike_newvalues[lastindex-60:lastindex]]
			setmeancurrents.append(float(np.mean(found)))
			normalizedsetmeancurrents.append(float(np.mean(found))/area)
			#this way gave problem as underestimates the current values
			#found = [x for counter, x in enumerate(nospike_newvalues[0:len(atten_newvalues)]) if atten_newvalues[counter] == setattenuation]
			#setmeancurrents.append(float(np.mean(found)))

		#if want to remove offset
		'''
		for counter in range(len(setmeancurrents)):
			setmeancurrents[counter] = setmeancurrents[counter] - currentatzero #remove offset
		'''

		for counter, setattenvalue in enumerate(setattenvalues):
			print setattenvalue, setmeancurrents[counter] #to check linearity of sectors

		setattenvalues = [float(x)**(-1) for x in setattenvalues] #perform 1/attenfactor
		#tools.write_attenuationrootgraph(setattenvalues, normalizedsetmeancurrents, filename, "1/attenuation", "i", dir_summary)
		graphlinearity = classes.attenuationrootgraph(filename[5:9], setattenvalues, normalizedsetmeancurrents, filename, "1/attenuation", "i", dir_summary)
		#find spikes -> new part to use threshold over plateu at given attenuation filter without spikes
		spikecounter, filename, spikedates, spikeseconds, spikenames, spikeduration = search.findspikes_atgif(newvalues, atten_newvalues, setmeancurrents, setattenvalues, dates, newtimes, filename)

	if "i" in filename and "D" in filename:
		sectorscurrent = None
		nospike_meancurrent = None

	if "v" in filename: #it's a voltage file
		sectorsvoltage = filename[5:9]
		meanvoltage = np.mean(newvalues)

		#Identify drops
		valuesdeltas = np.diff(newvalues)
		valuesdeltas = [0]+valuesdeltas #differences in currents of voltages

		copynewvalues = copy.copy(newvalues)
		notrips_newvalues = search.removetrips(valuesdeltas, copynewvalues)
		notrips_meanvoltage = np.mean(notrips_newvalues)

		if "D" in filename:
			sectorsvoltage = None
			notrips_meanvoltage = None

	if "i" not in filename or "D" in filename:
		spikenames = None
		duration = None
		spikeseconds = None
		spikeduration = None

	#write layer graphs
	#tools.write_roothistogram(newvalues, filename, filename[0], "Entries", rootdirectory) #if you want additional histograms

	if "i" in filename and "D" not in filename:
		#tools.write_rootdategraph_fromgif(rootdates, nospike_newvalues, filename, "time (s)", filename[0], rootdirectory) #plot graphs
		#tools.write_rootdategraph_plusatten(new_rootdates, newvalues, atten_newvalues, filename, "time (s)", filename[0], rootdirectory) #plot graph current + source
		graph_atten = classes.rootdategraph_plusatten(filename[5:9], new_rootdates, newvalues, atten_newvalues, filename, "time (s)", filename[0], rootdirectory)											     #or nospike_newvalues
		tools.write_rootdategraph_fromgif(rootdates, newvalues, filename, "time (s)", filename[0], rootdirectory)
	else:
		tools.write_rootdategraph_fromgif(rootdates, newvalues, filename, "time (s)", filename[0], rootdirectory) #plot graphs
		graph_atten = None
		graphlinearity = None

	#tools.write_rootdategraph_fromgif(rootdates, newvalues, filename, "time (s)", filename[0], rootdirectory) #plot graphs

	if "D" not in filename:
		#create trees
		if "i" in filename:
			tree = TTree(filename, "tree")
			newvalue = array( 'f', [ 0 ] )
			branch = tree.Branch(filename, newvalue, "newvalue/F")

			treesource = TTree(filename+"_source", "tree")
			atten = array('f', [0])
			branch = treesource.Branch(filename, atten, "atten/F")
			for i in range(len(newvalues)):
				newvalue[0] = newvalues[i]
				tree.Fill()
				if i<len(atten_newvalues):
					atten[0] = atten_newvalues[i]
					treesource.Fill()
			tree.Write()
			treesource.Write()
		if "v" in filename:
			tree = TTree(filename, "tree")
			newvalue = array( 'f', [ 0 ] )
			branch = tree.Branch(filename, newvalue, "newvalue/F")
			for i in range(len(newvalues)):
				newvalue[0] = newvalues[i]
				tree.Fill()
			tree.Write()

	return graph_atten, graphlinearity, spikenames, spikeduration, duration, sectorsvoltage, notrips_meanvoltage, sectorscurrent, nospike_meancurrent, spikeseconds
コード例 #9
0
    def __init__(self, fill, begin=TDatime(), stable=TDatime(), end=TDatime()):
        self._fill = fill
        self._begin = begin
        self._stable = stable
        self._end = end

        #Times in the dict below are approximate, to make the plots look better
        self._fillTimeDict = {
            # 0 - begin plot time
            # 1 - stable beams
            # 2 - end stable

            # Note: not all the Fills are in this list!
            '5423': [
                TDatime(2016, 10, 17, 21, 00, 00),
                TDatime(2016, 10, 18, 12, 00, 00),
                #TDatime(2016,10,17,22,00,00),
                TDatime(2016, 10, 18, 16, 35, 00)
            ],
            '5422': [
                TDatime(2016, 10, 17, 14, 00, 00),
                TDatime(2016, 10, 17, 14, 25, 00),
                TDatime(2016, 10, 17, 19, 25, 00)
            ],
            '4690': [
                TDatime(2015, 12, 03, 20, 30, 00),
                TDatime(2015, 12, 03, 22, 10, 00),
                TDatime(2015, 12, 04, 6, 37, 00)
            ],
            '4689': [
                TDatime(2015, 12, 03, 4, 30, 00),
                TDatime(2015, 12, 03, 9, 03, 00),
                TDatime(2015, 12, 03, 18, 10, 00)
            ],
            '4634': [
                TDatime(2015, 11, 19, 8, 00, 00),
                TDatime(2015, 11, 19, 14, 40, 00),
                TDatime(2015, 11, 20, 6, 20, 00)
            ],
            '4569': [
                TDatime(2015, 11, 2, 16, 40, 00),
                TDatime(2015, 11, 2, 19, 05, 00),
                TDatime(2015, 11, 3, 6, 25, 00)
            ],
            '4565': [
                TDatime(2015, 11, 2, 7, 30, 00),
                TDatime(2015, 11, 2, 8, 40, 00),
                TDatime(2015, 11, 2, 10, 55, 00)
            ],
            '4463': [
                TDatime(2015, 10, 5, 19, 00, 00),
                TDatime(2015, 10, 5, 20, 13, 00),
                TDatime(2015, 10, 6, 00, 20, 00)
            ],
            '4384': [
                TDatime(2015, 9, 17, 18, 00, 00),
                #TDatime(2015,9,17,20,00,00),
                TDatime(2015, 9, 17, 20, 20, 00),
                TDatime(2015, 9, 18, 10, 20, 00)
            ],
            '4381': [
                TDatime(2015, 9, 16, 23, 00, 00),
                TDatime(2015, 9, 17, 1, 45, 00),
                TDatime(2015, 9, 17, 13, 15, 00)
            ],
            '4269': [
                TDatime(2015, 8, 25, 12, 00, 00),
                TDatime(2015, 8, 25, 14, 30, 00),
                TDatime(2015, 8, 26, 3, 36, 00)
            ],
            '4266': [
                TDatime(2015, 8, 24, 20, 00, 00),
                TDatime(2015, 8, 24, 21, 05, 00),
                TDatime(2015, 8, 25, 7, 00, 00)
            ],
            '3858': [
                TDatime(2015, 6, 14, 06, 00, 00),
                TDatime(2015, 6, 14, 06, 35, 00),
                TDatime(2015, 6, 14, 15, 25, 00)
            ],
            '3857': [
                TDatime(2015, 6, 13, 16, 00, 00),
                TDatime(2015, 6, 13, 17, 12, 00),
                TDatime(2015, 6, 14, 04, 00, 00)
            ],
            '3855': [
                TDatime(2015, 6, 12, 19, 40, 00),
                TDatime(2015, 6, 12, 20, 18, 00),
                TDatime(2015, 6, 13, 10, 22, 00)
            ],
            '3851': [
                TDatime(2015, 6, 11, 02, 00, 00),
                TDatime(2015, 6, 11, 03, 00, 00),
                TDatime(2015, 6, 11, 14, 10, 00)
            ],
            '3474': [
                TDatime(2013, 1, 20, 13, 00, 00),
                TDatime(2013, 1, 20, 14, 10, 00),
                TDatime(2013, 1, 20, 16, 05, 00)
            ],
            '3478': [
                TDatime(2013, 1, 20, 23, 00, 00),
                TDatime(2013, 1, 21, 00, 50, 00),
                TDatime(2013, 1, 21, 03, 05, 00)
            ],
            '3378': [
                TDatime(2012, 12, 5, 21, 30, 00),
                TDatime(2012, 12, 5, 22, 00, 00),
                TDatime(2012, 12, 6, 00, 30, 00)
            ],
            '3047': [
                TDatime(2012, 9, 9, 14, 50, 00),
                TDatime(2012, 9, 9, 17, 30, 00),
                TDatime(2012, 9, 10, 04, 00, 00)
            ],
            '3053': [
                TDatime(2012, 9, 10, 14, 30, 00),
                TDatime(2012, 9, 10, 15, 00, 00),
                TDatime(2012, 9, 10, 20, 50, 00)
            ],
            '3054': [
                TDatime(2012, 9, 10, 21, 00, 00),
                TDatime(2012, 9, 11, 10, 00, 00),
                TDatime(2012, 9, 11, 13, 15, 00)
            ],
            '2872': [
                TDatime(2012, 07, 23, 19, 00, 00),
                TDatime(2012, 07, 23, 20, 15, 00),
                TDatime(2012, 07, 24, 8, 10, 00)
            ],
            '2871': [
                TDatime(2012, 07, 22, 9, 00, 00),
                TDatime(2012, 07, 22, 9, 50, 00),
                TDatime(2012, 07, 22, 14, 45, 00)
            ],
            '2825': [
                TDatime(2012, 07, 10, 02, 10, 00),
                TDatime(2012, 07, 10, 02, 30, 00),
                TDatime(2012, 07, 10, 02, 45, 00)
            ],
            '2824': [
                TDatime(2012, 07, 10, 05, 00, 00),
                TDatime(2012, 07, 10, 05, 10, 00),
                TDatime(2012, 07, 10, 05, 35, 00)
            ],
            '2798': [
                TDatime(2012, 07, 02, 17, 00, 00),
                TDatime(2012, 07, 02, 17, 25, 00),
                TDatime(2012, 07, 02, 18, 00, 00)
            ],
            '2739': [
                TDatime(2012, 06, 18, 8, 00, 00),
                TDatime(2012, 06, 18, 8, 30, 00),
                TDatime(2012, 06, 18, 11, 00, 00)
            ],
            '2723': [
                TDatime(2012, 06, 11, 12, 00, 00),
                TDatime(2012, 06, 11, 12, 35, 00),
                TDatime(2012, 06, 11, 15, 00, 00)
            ],
            '2718': [
                TDatime(2012, 06, 10, 06, 30, 00),
                TDatime(2012, 06, 10, 06, 51, 00),
                TDatime(2012, 06, 10, 21, 40, 00)
            ],
            '2698': [
                TDatime(2012, 06, 04, 17, 00, 00),
                TDatime(2012, 06, 04, 17, 30, 00),
                TDatime(2012, 06, 04, 22, 25, 00)
            ],
            '2692': [
                TDatime(2012, 06, 02, 05, 00, 00),
                TDatime(2012, 06, 02, 05, 15, 00),
                TDatime(2012, 06, 03, 03, 50, 00)
            ],
            '2635': [
                TDatime(2012, 05, 17, 04, 00, 00),
                TDatime(2012, 05, 17, 04, 50, 00),
                TDatime(2012, 05, 17, 9, 55, 00)
            ],
            '2634': [
                TDatime(2012, 05, 17, 01, 00, 00),
                TDatime(2012, 05, 17, 01, 17, 00),
                TDatime(2012, 05, 17, 02, 38, 00)
            ],
            '2632': [
                TDatime(2012, 05, 16, 18, 00, 00),
                TDatime(2012, 05, 16, 18, 55, 00),
                TDatime(2012, 05, 16, 19, 03, 00)
            ],
            '2634': [
                TDatime(2012, 05, 17, 01, 00, 00),
                TDatime(2012, 05, 17, 01, 17, 00),
                TDatime(2012, 05, 17, 02, 38, 00)
            ],
            '2630': [
                TDatime(2012, 05, 15, 20, 00, 00),
                TDatime(2012, 05, 15, 21, 00, 00),
                TDatime(2012, 05, 16, 01, 05, 00)
            ],
            '2629': [
                TDatime(2012, 05, 15, 12, 00, 00),
                TDatime(2012, 05, 15, 12, 30, 00),
                TDatime(2012, 05, 15, 18, 20, 00)
            ],
            '2616': [
                TDatime(2012, 05, 11, 11, 00, 00),
                TDatime(2012, 05, 11, 12, 05, 00),
                TDatime(2012, 05, 11, 13, 55, 00)
            ],
            '2609': [
                TDatime(2012, 05, 10, 18, 00, 00),
                TDatime(2012, 05, 10, 18, 41, 00),
                TDatime(2012, 05, 10, 23, 00, 00)
            ],
            '2608': [
                TDatime(2012, 05, 10, 15, 00, 00),
                TDatime(2012, 05, 10, 15, 36, 00),
                TDatime(2012, 05, 10, 16, 05, 00)
            ],
            '2534': [
                TDatime(2012, 04, 19, 3, 00, 00),
                TDatime(2012, 04, 19, 3, 55, 00),
                TDatime(2012, 04, 19, 8, 05, 00)
            ],
            '2523': [
                TDatime(2012, 04, 17, 04, 00, 00),
                TDatime(2012, 04, 17, 04, 25, 00),
                TDatime(2012, 04, 17, 11, 20, 00)
            ],
            '2493': [
                TDatime(2012, 04, 9, 07, 00, 00),
                TDatime(2012, 04, 9, 8, 35, 00),
                TDatime(2012, 04, 9, 14, 50, 00)
            ],
            '2491': [
                TDatime(2012, 04, 8, 15, 30, 00),
                TDatime(2012, 04, 8, 16, 25, 00),
                TDatime(2012, 04, 9, 02, 35, 00)
            ],
            '2490': [
                TDatime(2012, 04, 8, 11, 00, 00),
                TDatime(2012, 04, 8, 12, 55, 00),
                TDatime(2012, 04, 8, 14, 10, 00)
            ],
            '2489': [
                TDatime(2012, 04, 8, 04, 30, 00),
                TDatime(2012, 04, 8, 05, 15, 00),
                TDatime(2012, 04, 8, 9, 30, 00)
            ],
            '2488': [
                TDatime(2012, 04, 07, 22, 00, 00),
                TDatime(2012, 04, 07, 22, 50, 00),
                TDatime(2012, 04, 8, 03, 00, 00)
            ],
            '2486': [
                TDatime(2012, 04, 07, 16, 00, 00),
                TDatime(2012, 04, 07, 17, 20, 00),
                TDatime(2012, 04, 07, 18, 45, 00)
            ],
            '2482': [
                TDatime(2012, 04, 06, 22, 00, 00),
                TDatime(2012, 04, 07, 0, 05, 00),
                TDatime(2012, 04, 07, 03, 35, 00)
            ],
            '2479': [
                TDatime(2012, 04, 06, 11, 00, 00),
                TDatime(2012, 04, 06, 12, 55, 00),
                TDatime(2012, 04, 06, 15, 50, 00)
            ],
            '2472': [
                TDatime(2012, 04, 05, 16, 30, 00),
                TDatime(2012, 04, 05, 17, 55, 00),
                TDatime(2012, 04, 05, 22, 15, 00)
            ],
            '2471': [
                TDatime(2012, 04, 05, 12, 30, 00),
                TDatime(2012, 04, 05, 13, 30, 00),
                TDatime(2012, 04, 05, 15, 45, 00)
            ],
            '2470': [
                TDatime(2012, 04, 05, 03, 10, 00),
                TDatime(2012, 04, 05, 03, 40, 00),
                TDatime(2012, 04, 05, 07, 40, 00)
            ],
            '2469': [
                TDatime(2012, 04, 04, 22, 10, 00),
                TDatime(2012, 04, 04, 22, 40, 00),
                TDatime(2012, 04, 05, 00, 10, 00)
            ],

            #Below are the Fills from HI data 2011
            '2318': [
                TDatime(2011, 11, 23, 20, 10, 00),  #0 begin plot time
                TDatime(2011, 11, 23, 21, 00, 00),  #1 stable beams
                TDatime(2011, 11, 24, 2, 30, 00)  #2 end
            ],
            '2319': [
                TDatime(2011, 11, 24, 8, 00, 00),
                TDatime(2011, 11, 24, 8, 10, 00),
                TDatime(2011, 11, 24, 17, 00, 00)
            ],
            '2320': [
                TDatime(2011, 11, 24, 21, 45, 00),
                TDatime(2011, 11, 24, 21, 45, 00),
                TDatime(2011, 11, 25, 3, 10, 00)
            ],
            '2332': [
                TDatime(2011, 11, 28, 17, 45, 00),
                TDatime(2011, 11, 28, 18, 15, 00),
                TDatime(2011, 11, 28, 19, 20, 00)
            ],
            '2334': [
                TDatime(2011, 12, 01, 3, 00, 00),
                TDatime(2011, 12, 01, 4, 00, 00),
                TDatime(2011, 12, 01, 9, 40, 00)
            ],
            '2335': [
                TDatime(2011, 12, 01, 13, 00, 00),
                TDatime(2011, 12, 01, 14, 35, 00),
                TDatime(2011, 12, 01, 20, 10, 00)
            ],
            '2336': [
                TDatime(2011, 12, 02, 2, 00, 00),
                TDatime(2011, 12, 02, 3, 20, 00),
                TDatime(2011, 12, 02, 9, 30, 00)
            ],
            '2337': [
                TDatime(2011, 12, 02, 11, 30, 00),
                TDatime(2011, 12, 02, 12, 20, 00),
                TDatime(2011, 12, 02, 16, 30, 00)
            ],
            '2338': [
                TDatime(2011, 12, 02, 22, 30, 00),
                TDatime(2011, 12, 02, 23, 30, 00),
                TDatime(2011, 12, 03, 07, 05, 00)
            ],
            '2339': [
                TDatime(2011, 12, 03, 12, 00, 00),
                TDatime(2011, 12, 03, 13, 10, 00),
                TDatime(2011, 12, 03, 19, 00, 00)
            ],
            '2340': [
                TDatime(2011, 12, 03, 21, 00, 00),
                TDatime(2011, 12, 03, 22, 00, 00),
                TDatime(2011, 12, 04, 05, 00, 00)
            ],
            '2341': [
                TDatime(2011, 12, 04, 10, 10, 00),
                TDatime(2011, 12, 04, 10, 50, 00),
                TDatime(2011, 12, 04, 13, 55, 00)
            ],
            '2342': [
                TDatime(2011, 12, 04, 16, 40, 00),
                TDatime(2011, 12, 04, 17, 30, 00),
                TDatime(2011, 12, 04, 22, 55, 00)
            ],
            '2343': [
                TDatime(2011, 12, 05, 1, 30, 00),
                TDatime(2011, 12, 05, 2, 20, 00),
                TDatime(2011, 12, 05, 8, 35, 00)
            ],
            '2344': [
                TDatime(2011, 12, 05, 21, 00, 00),
                TDatime(2011, 12, 05, 21, 55, 00),
                TDatime(2011, 12, 06, 4, 55, 00)
            ],
            '2349': [
                TDatime(2011, 12, 06, 19, 20, 00),
                TDatime(2011, 12, 06, 20, 05, 00),
                TDatime(2011, 12, 06, 21, 35, 00)
            ]
        }
コード例 #10
0
ファイル: graphUtils.py プロジェクト: namcneal/QY
 def getTDatime(self,dt,fmt='%Y/%m/%d %H:%M:%S'):
     '''
     convert date/time text to TDatime object
     '''
     datetimeObj = self.getdatetime(dt,fmt=fmt)
     return TDatime( datetimeObj.strftime('%Y-%m-%d %H:%M:%S') ).Convert()
コード例 #11
0
        self.__canvas.SetBorderSize(2)
        self.__canvas.SetGridx()
        self.__canvas.SetGridy()
        self.__canvas.SetFrameFillColor(19)
        self.__canvas.SetFrameBorderMode(0)
        self.__canvas.SetFrameBorderMode(0)
        self.__outfile=outputfilename
    def draw(self,rootobj):
        rootobj.Draw()
        self.__canvas.Modified()
        self.__canvas.cd()
        self.__canvas.SetSelected(rootobj)
        self.__canvas.SaveAs(self.__outfile)
if __name__=='__main__':
      
    da = TDatime(2010,3,30,13,10,00)
    h1f = TH1F("Luminposity","",1000,0.,1000)
    h1f.GetXaxis().SetNdivisions(-503)
    h1f.GetXaxis().SetTimeDisplay(1)
    h1f.GetXaxis().SetTimeFormat("%d\/%m %H:%M")
    h1f.GetXaxis().SetTimeOffset(da.Convert())       
    h1f.GetXaxis().SetLabelFont(32);
    h1f.GetXaxis().SetLabelSize(0.03);
    h1f.GetXaxis().SetTitleFont(32);
    h1f.GetXaxis().SetTitle("Date");
        
    h1f.GetYaxis().SetLabelFont(32);
    h1f.GetYaxis().SetLabelSize(0.03);
    h1f.GetYaxis().SetTitleFont(32);
    h1f.GetYaxis().SetTitle("L (#mub^{-1})");
    
コード例 #12
0
    def __init__(self):
        tk.Frame.__init__(self, master=master)
        ROOT.gROOT.SetBatch(ROOT.kFALSE)
        #ROOT.gROOT.SetBatch(ROOT.kTRUE)
        ROOT.gStyle.SetOptStat(0)

        da = TDatime(2010, 3, 30, 13, 10, 00)

        c = TCanvas("Luminosity", "", 1)

        c.SetHighLightColor(2)
        c.Range(-125.6732, -0.1364721, 1123.878, 1.178117)
        c.SetFillColor(0)
        c.SetBorderMode(0)
        c.SetBorderSize(2)
        c.SetGridx()
        c.SetGridy()
        c.SetFrameFillColor(19)
        c.SetFrameBorderMode(0)
        c.SetFrameBorderMode(0)

        h1f = TH1F("Luminposity", "", 1000, 0., 1000)
        h1f.GetXaxis().SetNdivisions(-503)
        h1f.GetXaxis().SetTimeDisplay(1)
        h1f.GetXaxis().SetTimeFormat("%d\/%m %H:%M")
        h1f.GetXaxis().SetTimeOffset(da.Convert())
        h1f.GetXaxis().SetLabelFont(32)
        h1f.GetXaxis().SetLabelSize(0.03)
        h1f.GetXaxis().SetTitleFont(32)
        h1f.GetXaxis().SetTitle("Date")

        h1f.GetYaxis().SetLabelFont(32)
        h1f.GetYaxis().SetLabelSize(0.03)
        h1f.GetYaxis().SetTitleFont(32)
        h1f.GetYaxis().SetTitle("L (#mub^{-1})")

        for i in range(0, 1000):
            #h1f.GetXaxis().FindBin() ## Ricordati di calcolare il bin corretto per il tuo tempo
            h1f.SetBinContent(i, 20.2 + i)

        h1f.Draw()

        h1f2 = TH1F("Luminposity 2", "", 1000, 0., 1000)
        h1f2.GetXaxis().SetNdivisions(-503)
        h1f2.GetXaxis().SetTimeDisplay(1)
        h1f2.GetXaxis().SetTimeFormat("%d\/%m %H:%M")
        h1f2.GetXaxis().SetTimeOffset(da.Convert())
        h1f2.GetXaxis().SetLabelSize(0.03)

        for i in range(0, 1000):
            h1f2.SetBinContent(i, 20.2 - i)

        h1f2.SetLineColor(ROOT.kRed)
        h1f2.Draw("same")

        leg = TLegend(0.1537356, 0.6631356, 0.5344828, 0.875)
        leg.SetTextFont(32)
        leg.SetFillColor(0)
        leg.SetFillStyle(1001)

        leg.AddEntry(h1f, "Delibvered 1.54 nb^{-1}", "l")
        leg.AddEntry(h1f2, "Delibvered 1.59 nb^{-1}", "l")
        leg.Draw()

        #c.Modified();
        #c.cd();
        #c.SetSelected(h1f);

        #c.SaveAs("Zhen.jpg")

        self.pack()
        button = tk.Button(master=master, text='Quit', command=sys.exit)
        button.pack(side=tk.BOTTOM)
        tk.mainloop()
コード例 #13
0
ファイル: pandsusers.py プロジェクト: vfine/webplatform
    def doMain(self,
               file='useact',
               dir='/home/fine/panda/pandamon/static/data',
               options='',
               dateformat='%y%m%d'):
        if dir == None or dir == '':
            dir = '/home/fine/panda/pandamon/static/root'
        if file == None or file == '': file = 'fillrandom.root'
        false = False
        null = None
        try:
            f = open("%s/%s.json" % (dir, file))
            print f
        except:
            raise
        info = []
        info = [["JSON File", "%s" % file]]
        try:
            jdata = eval(f.read())
        except:
            raise
        data = jdata['pm'][0]['json']['buffer']['data']
        header = data[0]
        rows = data[1]
        timeOffset = 0
        minTime = None
        maxTime = None
        for i, r in enumerate(rows):
            if i == 0:
                minTime = datetime.strptime("%s" % r[0], dateformat)
                maxTime = minTime
            timeStamp = datetime.strptime("%s" % r[0], dateformat)
            if timeStamp < minTime: minTime = timeStamp
            if timeStamp > maxTime: maxTime = timeStamp
        maxTime += timedelta(days=1)
        timeOffset = minTime
        duration = total_seconds(maxTime - minTime)
        nbins = (maxTime - minTime).days
        h = TH1F(
            file, 'The PANDA users activity for the last %s days ' %
            (duration / (3600 * 24) - 1), nbins, 0, duration)
        for r in rows:
            time = total_seconds(
                datetime.strptime("%s" % r[0], dateformat) - timeOffset +
                timedelta(hours=12))
            h.Fill(time)

        h.GetYaxis().SetTitle("Users")
        xaxis = h.GetXaxis()
        xaxis.SetTimeDisplay(1)
        da = TDatime(timeOffset.year, timeOffset.month, timeOffset.day, 0, 0,
                     0).Convert()
        xaxis.SetTimeOffset(da)
        gStyle.SetTimeOffset(da)
        xaxis.SetTitle("%s" % maxTime.year)

        rootfile = gDirectory
        info.append(['File', directory().serialize(rootfile)])
        lineColor = None
        rhists = []
        if True:
            h1f = h
            hColor = h1f.GetLineColor()
            if hColor == lineColor:
                fillColor = h1f.GetFillColor()
                h1f.SetLineColor(fillColor)
            lineColor = hColor
            h2sell = sh1f().serialize(h1f)
            h2sell['data']['options'] += options
            rhists.append(h2sell)
        info.append(['Histogram', rhists])
        info.append(['Name', "<b>%s</b>" % h1f.GetName()])
        info.append(['Title', "<b>%s</b>" % h1f.GetTitle()])
        nx = range(1, h1f.GetNbinsX())
        info.append(['integral', h1f.Integral()])
        print >> self._file, info
        self._file.close()
        return info
コード例 #14
0
def createplot(file, filename):

    layer = filename[5:7]
    if "D" not in layer and "HO" not in layer:
        rootdirectory = directories[layer]  #to check

    times = [x.split(' 	 ')[0] for x in open(file, "r").readlines()]
    if len(times) == 1:
        print "Exception -----> Only one data in " + str(filename) + ".dat \n"
        return None, None, None, None, None, None, None, None
    if not times:
        print "Exception -----> File empty: " + str(filename) + ".dat \n"
        return None, None, None, None, None, None, None, None

    times = [x.replace(':', ' ') for x in times]
    times = [x.replace('/', ' ') for x in times]
    times = [x.replace('_', ' ') for x in times]
    times = [dt.strptime(x, '%m %d %Y %H %M %S') for x in times]

    starttime = times[0]
    dates = [starttime]

    times = [int((x - starttime).total_seconds()) for x in times]

    values = [float(x.split(' 	 ')[1]) for x in open(file, "r").readlines()]

    newtimes = range(times[len(times) - 1])
    newvalues = [None] * len(newtimes)

    for counter, value in enumerate(newvalues):
        if counter in times:
            newvalues[counter] = values[times.index(counter)]
        else:
            newvalues[counter] = newvalues[counter - 1]

    for counter in range(len(newtimes) - 1):
        dates.append(dates[counter] + td(seconds=1))

    rootdates = [
        TDatime(x.year, x.month, x.day, x.hour, x.minute, x.second)
        for x in dates
    ]

    #Identify drops
    valuesdeltas = np.diff(newvalues)
    valuesdeltas = [0] + valuesdeltas

    sectorscurrent = None
    sectorsvoltage = None
    meancurrent = None
    nospike_meancurrent = None
    meanvoltage = None
    notrips_meanvoltage = None

    if "i" in filename:  #it's a current file
        #search.findrisingedges(valuesdeltas, dates)
        #search.findfallingedges(valuesdeltas, dates)

        sectorscurrent = filename[5:9]
        meancurrent = np.mean(newvalues)

        #remove spikes in current files
        copynewvalues = copy.copy(
            newvalues)  #need to copy it to pass to function below
        nospike_newvalues = search.removespikes(valuesdeltas, copynewvalues)
        nospike_meancurrent = np.mean(
            nospike_newvalues)  #used to have real baseline of the current
        #or meancurrent
        spikecounter, filename, spikedates, spikeseconds, spikenames = search.findspikes_50na(
            newvalues, meancurrent, dates, newtimes, filename)
        #spikecounter, filename, spikedates, spikeseconds, spikenames = search.findspikes(valuesdeltas, dates, newtimes, filename) #old one

        if "D" in filename:
            sectorscurrent = None
            nospike_meancurrent = None
        if "HO" in filename:
            sectorscurrent = None
            nospike_meancurrent = None

    if "v" in filename:  #it's a voltage file
        sectorsvoltage = filename[5:9]
        meanvoltage = np.mean(newvalues)

        copynewvalues = copy.copy(newvalues)
        notrips_newvalues = search.removetrips(valuesdeltas, copynewvalues)
        notrips_meanvoltage = np.mean(notrips_newvalues)

        if "D" in filename:
            sectorsvoltage = None
            notrips_meanvoltage = None
        if "HO" in filename:
            sectorscurrent = None
            nospike_meancurrent = None

    #tools.write_roothistogram(newvalues, filename, filename[0], "Entries", rootdirectory) #if want additional histograms
    if "D" not in filename and "HO" not in filename:
        tools.write_rootdategraph(rootdates, newvalues, filename, "time (s)",
                                  filename[0], rootdirectory)
        currentgraph = classes.currentgraph(filename[5:9], rootdates,
                                            newvalues, filename, "time (s)",
                                            filename[0], rootdirectory)

    #create trees for voltages branch
    if "v" in filename:
        tree = TTree(filename, "tree")
        newvalue = array('f', [0])
        branch = tree.Branch(filename, newvalue, "newvalue/F")
        for i in range(len(newvalues)):
            newvalue[0] = newvalues[i]
            tree.Fill()
        tree.Write()

    duration = len(newtimes)  #total seconds from start to stop

    if "i" not in filename or "D" in filename or "HO" in filename:
        spikenames = None
        duration = None
        spikeseconds = None
        currentgraph = None

    return currentgraph, spikenames, duration, sectorsvoltage, notrips_meanvoltage, sectorscurrent, nospike_meancurrent, spikeseconds