def formHistogram(outputFile, listOfDirs): global numBins, volts, eSqH, binSize, listOfBins listOfBins = functions.createZeroedList(numBins) dataBuffer = functions.createZeroedList(diffSize) fs = None for count, directory in enumerate(listOfDirs): success = True try: fs = open(directory, "r") #print("Successfully opened "+directory) except: print("FAILED to open "+directory) success = False if success == True: #read file data = [] maximum = 0 minimum = 0 for line in fs: cell = line.split(",") cell[4] = float(cell[4]) writeVoltages(cell[4], count) if cell[4] > maximum: maximum = cell[4] elif cell[4] < minimum: minimum = cell[4] data.append(cell[4]-dataBuffer[0]) print(dataBuffer) dataBuffer = shuffleListAlong(float(cell[4]), dataBuffer) ''' if abs(maximum) > abs(minimum): if(abs(maximum) < 1.67): writeDiffData(data, abs(maximum)) elif abs(maximum) < abs(minimum): writeDiffData(data, abs(minimum)) else: print("UH OH!") ''' for i in range(0, len(data), 10): if i<len(data): #writeVoltages(data[i]) pass print("finished")
def formHistogram(outputFile, listOfDirs): global maximum, minimum, numBins, volts, eSqH, binSize, listofBins, shifts fs = None listOfBins = functions.createZeroedList(numBins) print("Number of files opened: " + str(len(listOfDirs))) print("Min = " + str(minimum) + " Max = " + str(maximum)) binSize = (maximum - minimum) / (numBins - 1) print("BinSize = " + str(binSize)) #go through file sorting data for i in range(0, len(listOfDirs), 1): success = True try: fs = open(listOfDirs[i], "r") #print("Successfully opened "+listOfDirs[i]) except: print("FAILED to open " + listOfDirs[i]) success = False if success == True: #read file for line in fs: cell = line.split(",") cell[4] = functions.convert(float(cell[4]), volts, eSqH) - shifts[i] if cell[4] < 14 and cell[4] > 0: listOfBins[int(float(cell[4] - minimum) / (binSize))] += 1 fs.close() print("Finished.") #Estimate peaks baseAvg = functions.findBaselineAvg(listOfBins, numBins) peakData = functions.findpeaks(listOfBins, numBins, binSize, baseAvg) print("Calculating peaks...") peakXVal = [] for peak in peakData: peakXVal.append(peak * binSize) print("Peaks found at ") print(peakXVal) #write results to a file fs = open(outputFile, "w") j = 0 halfBin = binSize / 2 for i in range(0, numBins, 1): try: if peakData[j] == i: fs.write((str((i * binSize) + minimum + halfBin)) + "," + str(listOfBins[i]) + ",10000," + str(baseAvg[i]) + "\n") j += 1 else: fs.write((str((i * binSize) + minimum + halfBin)) + "," + str(listOfBins[i]) + ",0," + str(baseAvg[i]) + "\n") except: fs.write((str((i * binSize) + minimum + halfBin)) + "," + str(listOfBins[i]) + ",0," + str(baseAvg[i]) + "\n") print("Output File created.") fs.close()
def formHistogram(outputFile, listOfDirs): global numBins, volts, eSqH, binSize, listOfBins listOfBins = functions.createZeroedList(numBins) dataBuffer = functions.createZeroedList(diffSize) fs = None for count, directory in enumerate(listOfDirs): success = True try: fs = open(directory, "r") #print("Successfully opened "+directory) except: print("FAILED to open " + directory) success = False if success == True: #read file data = [] maximum = 0 minimum = 0 for line in fs: cell = line.split(",") cell[4] = float(cell[4]) writeVoltages(cell[4], count) if cell[4] > maximum: maximum = cell[4] elif cell[4] < minimum: minimum = cell[4] data.append(cell[4] - dataBuffer[0]) print(dataBuffer) dataBuffer = shuffleListAlong(float(cell[4]), dataBuffer) ''' if abs(maximum) > abs(minimum): if(abs(maximum) < 1.67): writeDiffData(data, abs(maximum)) elif abs(maximum) < abs(minimum): writeDiffData(data, abs(minimum)) else: print("UH OH!") ''' for i in range(0, len(data), 10): if i < len(data): #writeVoltages(data[i]) pass print("finished")
def formHistogram(outputFile, listOfDirs): global maximum, minimum, numBins, volts, eSqH, binSize, listofBins, shifts fs = None listOfBins = functions.createZeroedList(numBins) print("Number of files opened: "+str(len(listOfDirs))) print("Min = "+str(minimum)+" Max = "+str(maximum)) binSize = (maximum-minimum)/(numBins-1) print("BinSize = "+str(binSize)) #go through file sorting data for i in range(0, len(listOfDirs), 1): success = True try: fs = open(listOfDirs[i], "r") #print("Successfully opened "+listOfDirs[i]) except: print("FAILED to open "+listOfDirs[i]) success = False if success == True: #read file for line in fs: cell = line.split(",") cell[4] = functions.convert(float(cell[4]), volts, eSqH) - shifts[i] if cell[4] < 14 and cell[4] > 0: listOfBins[int(float(cell[4]-minimum)/(binSize))] += 1 fs.close() print("Finished.") #Estimate peaks baseAvg = functions.findBaselineAvg(listOfBins, numBins) peakData = functions.findpeaks(listOfBins, numBins, binSize, baseAvg) print("Calculating peaks...") peakXVal = [] for peak in peakData: peakXVal.append(peak*binSize) print("Peaks found at ") print(peakXVal) #write results to a file fs = open(outputFile, "w") j = 0 halfBin = binSize/2 for i in range(0, numBins, 1): try: if peakData[j] == i: fs.write((str((i*binSize)+minimum+halfBin))+","+str(listOfBins[i])+",10000,"+str(baseAvg[i])+"\n") j+=1 else: fs.write((str((i*binSize)+minimum+halfBin))+","+str(listOfBins[i])+",0,"+str(baseAvg[i])+"\n") except: fs.write((str((i*binSize)+minimum+halfBin))+","+str(listOfBins[i])+",0,"+str(baseAvg[i])+"\n") print("Output File created.") fs.close()
def formHistogram(outputFile, listOfDirs): global maximum, minimum, numBins, volts, eSqH, binSize, listofBins, condData, steps, timeData, shifts, numEmpty fs = None listOfBins = functions.createZeroedList(numBins) print("Number of files opened: " + str(len(listOfDirs))) print("Min = " + str(minimum) + " Max = " + str(maximum)) binSize = (maximum - minimum) / (numBins - 1) print("BinSize = " + str(binSize)) #go through file sorting data for i in range(0, len(listOfDirs), 1): success = True try: fs = open(listOfDirs[i], "r") #print("Successfully opened "+directory) except: print("FAILED to open " + listOfDirs[i]) success = False if success == True: #read file for line in fs: cell = line.split(",") condData.append(functions.convert(float(cell[4]), volts, eSqH)) timeData.append(float(cell[3])) recursiveStepSearch(0, len(condData) - 1, condData, timeData) steps = functions.removeDuplicates(steps) steps = functions.removeMinMaxValues(steps, max(condData)) if len(steps) == 0: numEmpty += 1 for item in steps: listOfBins[int(float(item + abs(minimum)) / (binSize))] += 1 steps = [] condData = [] timeData = [] fs.close() print("Number of files where steps could not be detected: " + str(numEmpty)) #Estimate peaks baseAvg = functions.findBaselineAvg(listOfBins, numBins) peakData = functions.findpeaks(listOfBins, numBins, binSize, baseAvg) print("Calculating peaks...") peakXVal = [] for peak in peakData: peakXVal.append(peak * binSize) print("Peaks found at ") print(peakXVal) #write results to a file fs = open(outputFile, "w") j = 0 halfBin = binSize / 2 for i in range(0, numBins, 1): try: if peakData[j] == i: fs.write((str((i * binSize) - abs(minimum) + halfBin)) + "," + str(listOfBins[i]) + ",20," + str(baseAvg[i]) + "\n") j += 1 else: fs.write((str((i * binSize) - abs(minimum) + halfBin)) + "," + str(listOfBins[i]) + ",0," + str(baseAvg[i]) + "\n") except: fs.write((str((i * binSize) - abs(minimum) + halfBin)) + "," + str(listOfBins[i]) + ",0," + str(baseAvg[i]) + "\n") print("Output File created.") fs.close()
import functions e = 1.6e-19 h = 6.626e-34 eSqH = (2 * e * e) / h listOfDirs = functions.getList(functions.askForDir()) numBins = 200 volts = 15.18 numBins += 1 #to account for max data value listOfBins = functions.createZeroedList(numBins) maximum = 0 minimum = 0 shifts = [] def findMinAndMax(): global minimum, maximum, shifts, listOfDirs fs = None print("Reading in data...") # read through files and fine minimum/maximum data for i, directory in enumerate(listOfDirs): data = [] success = True try: fs = open(directory, "r") #print("Successfully opened "+directory) except: print("FAILED to open " + directory) success = False if success == True: #read file for line in fs:
def formHistogram(outputFile, listOfDirs): global maximum, minimum, numBins, volts, eSqH, binSize, listofBins, condData, timeData, stripSize, numSteps, steps, shifts, numEmpty listOfBins = functions.createZeroedList(numBins) print("Number of files opened: " + str(len(listOfDirs))) print("Min = " + str(minimum) + " Max = " + str(maximum)) binSize = (maximum - minimum) / (numBins - 1) print("BinSize = " + str(binSize)) print("Finding steps...") #go through file sorting data for i in range(0, len(listOfDirs), 1): success = True try: fs = open(listOfDirs[i], "r") #print("Successfully opened "+directory) except: print("FAILED to open " + listOfDirs[i]) success = False if success == True: #read file Empty = True for line in fs: cell = line.split(",") condData.append( functions.convert(float(cell[4]), volts, eSqH) - shifts[i]) timeData.append(float(cell[3])) marker = 0 while marker < stripSize: steps = [] while marker < (2500 - stripSize): stripDataX = [] stripDataY = [] for i in range(marker, marker + stripSize, 1): stripDataX.append(timeData[i]) stripDataY.append(condData[i]) b = functions.regressionFindB(stripDataX, stripDataY) sumY = 0 if abs(b) < 10000: # Fudge Factor numSteps += 1 for item in stripDataY: sumY += item sumY = sumY / stripSize steps.append(sumY) if len(steps) > 0: steps = functions.removeDuplicates(steps) steps = functions.removeMinMaxValues( steps, max(condData)) Empty = False marker += stripSize for item in steps: listOfBins[int(float(item + abs(minimum)) / (binSize))] += 1 marker += 1 if Empty == True: numEmpty += 1 condData = [] timeData = [] fs.close() print("Number of files where steps could not be detected: " + str(numEmpty)) #Estimate peaks baseAvg = functions.findBaselineAvg(listOfBins, numBins) peakData = functions.findpeaks(listOfBins, numBins, binSize, baseAvg) print("Calculating peaks...") peakXVal = [] for peak in peakData: peakXVal.append(peak * binSize) print("Peaks found at ") print(peakXVal) #write results to a file fs = open(outputFile, "w") j = 0 halfBin = binSize / 2 for i in range(0, numBins, 1): try: if peakData[j] == i: fs.write((str((i * binSize) - abs(minimum) + halfBin)) + "," + str(listOfBins[i]) + ",20," + str(baseAvg[i]) + "\n") j += 1 else: fs.write((str((i * binSize) - abs(minimum) + halfBin)) + "," + str(listOfBins[i]) + ",0," + str(baseAvg[i]) + "\n") except: fs.write((str((i * binSize) - abs(minimum) + halfBin)) + "," + str(listOfBins[i]) + ",0," + str(baseAvg[i]) + "\n") print("Output File created.") fs.close()
def formHistogram(outputFile, listOfDirs): global maximum, minimum, numBins, volts, eSqH, binSize, listofBins, listOfMinimums global prevcell, listdiff, listdata,value, runningavg, base, markers,k, total, count2, l, kref fs = None listOfBins = functions.createZeroedList(numBins) listOfMinimums = functions.createZeroedList(len(listOfDirs)) print("Reading in data...") # read through files and fine minimum/maximum data count = 0 for directory in listOfDirs: success = True try: fs = open(directory, "r") #print("Successfully opened "+directory) except: print("FAILED to open "+directory) success = False if success == True: #read file minTemp = 0 maxTemp = 0 for line in fs: cell = line.split(",") cell[4] = functions.convert(float(cell[4]), volts, eSqH) if float(cell[4]) > maximum: maximum = float(cell[4]) elif float(cell[4]) < minimum: minimum = float(cell[4]) #if float(cell[4]) > maxTemp: # maxTemp = float(cell[4]) #elif float(cell[4]) < minTemp: # minTemp = float(cell[4]) #listOfMinimums[count] = abs(minTemp) count = count + 1 print("Number of files opened: "+str(len(listOfDirs))) #print("Min = "+str(minimum)+" Max = "+str(maximum)) binSize = (maximum-minimum)/(numBins-1) print("BinSize = "+str(binSize)) #go through file sorting data for i in range(0, len(listOfDirs), 1): success = True try: fs = open(listOfDirs[i], "r") #print("Successfully opened "+listOfDirs[i]) except: print("FAILED to open "+listOfDirs[i]) success = False if success == True: #read file listdiff = [] runningavg = [] markers = [] listData = [] for x,line in enumerate(fs): listData.append(cell[4]) cell = line.split(",") cell[4] = functions.convert(float(cell[4]), volts, eSqH) #cell[4] = float(cell[4]) + float(listOfMinimums[i]) #listOfBins[int(float(cell[4]+abs(minimum))/(binSize))] += 1 if x >= stepsize: listdiff.append((cell[4] - listData[x-stepsize]) / ( stepsize*4*10e-7 ) ) #fopen=open("c:\\Users\\Thomas\\Desktop\\QCNLab\\qcnlab\\New folder\\outputFile_" + str(i)+ ".csv","w") count=len(listdiff) for x in range (3,count-2,1): #fopen.write(str((listdiff[x-2]+listdiff[x-1]+listdiff[x]+listdiff[x+1]+listdiff[x+2])/5) + "\n") runningavg.append((listdiff[x-2]+listdiff[x-1]+listdiff[x]+listdiff[x+1]+listdiff[x+2])/5) #functions.writeList(listdiff,fopen) avg = sum(runningavg)/count base = ((avg)+min(runningavg))/2 for x in range (1,count-5,1): if runningavg[x]<base: markers.append(x) count=len(markers) k=markers[0]+1 for x in range (0,count,1): if k!=markers[x]-1: count2 = 0 total = 0 #print("HI") for l in range (markers[x-1]+1,markers[x],1): count2 = count2 + 1 total = listData[l]+total #print("HELLO") if count2>0: #print("HOWDY") value.append(total/count2) k=markers[x] #fopen.close() fs.close() minimum = 0 maximum = max(value) print(maximum) binSize = (maximum)/(numBins-1) count=len(value) print(count) print(binSize) for i in range (0, count, 1): if value[i]>=0: listOfBins[int(value[i]/binSize)] += 1 #print(int(value[i]/binsize)) else: print("ERROR") #fopen=open("c:\\Users\\Thomas\\Desktop\\QCNLab\\qcnlab\\New folder\\outputFile.csv","w") fopen = open(outputFile, "w") for i in range (0,numBins,1): fopen.write(str((i*binSize)+(binSize/2))+","+str(listOfBins[i])+"\n") fopen.close() print("Finished.") ''' #Estimate peaks baseAvg = functions.findBaselineAvg(listOfBins, numBins) peakData = functions.findpeaks(listOfBins, numBins, binSize, baseAvg) print("Calculating peaks...") peakXVal = [] for peak in peakData: peakXVal.append(peak*binSize) print("Peaks found at ") print(peakXVal) ''' '''
def formHistogram(outputFile, listOfDirs): valueList = [] stepListVoltageValues = [] fs = None z=3 something = int(z/3) j=0 Top=0 Bottom=0 global numBins, volts, eSqH, binSize, listOfBins listOfBins = functions.createZeroedList(numBins) for count, directory in enumerate(listOfDirs): success = True try: fs = open(directory, "r") #print("Successfully opened "+directory) except: print("FAILED to open "+directory) success = False if success == True: valueList = [] for line in fs: cell = line.split(",") print(cell[4]+" "+str(float(cell[4]))) cell[4] = functions.convert(float(cell[4]), volts, eSqH) - shifts[count] if cell[4] > 0.3 and cell[4] < 14: valueList.append(float(cell[4])) for i in range (z, len(valueList), 1):#Start loop for at top value search Top=None if((valueList[i]-valueList[i-something])>((valueList[i-something]-valueList[i-2*something]))): Bottom = None Top = valueList[i-something] j=i-something #store index for last value assessed for z in range (j, len(valueList), 1): #now carry on only looking for a much smaller increment size to give bottom of step if (((valueList[z]-valueList[z-something])<=((valueList[z-something]-valueList[z-2*something]))*(1-0))): Bottom = valueList[z] #store last index assessed break #break out of loop so we can calc the step try: if(((Top-Bottom) >= 0.2*eSqH)): #filtering out the accidental mini steps stepListVoltageValues.append(Top) else: #print("false step between " + str(j) +"-" + str(i)) #explaining where we miscalc a step to then assess for debug print("nboithing") except: print("Nout") #minimum = min(stepListVoltageValues) #analyzing for the max and min range of step sizes, #maximum = max(stepListVoltageValues) binSize = (maximum - minimum)/(numBins-1) #To be done after data set has been full analyzed, so once while loop is ended print("min = "+str(minimum)+" max = "+str(maximum)+" BinSize = "+str(binSize)) print(functions.printList(stepListVoltageValues)) for i in range (0, len(stepListVoltageValues), 1): listOfBins[int((stepListVoltageValues[i]-minimum)/binSize)] +=1 #print(int((stepListVoltageValues[i]-minimum)/binSize)) fs = open(outputFile, "w") #make the histo halfBin = binSize/2 for i, item in enumerate(listOfBins): fs.write((str((i*binSize)+halfBin))+","+str(item)+"\n") print("Output File created.") fs.close()
def formHistogram(outputFile, listOfDirs): global maximum, minimum, numBins, volts, eSqH, binSize, listofBins, condData, steps, timeData, shifts, numEmpty fs = None listOfBins = functions.createZeroedList(numBins) print("Number of files opened: "+str(len(listOfDirs))) print("Min = "+str(minimum)+" Max = "+str(maximum)) binSize = (maximum-minimum)/(numBins-1) print("BinSize = "+str(binSize)) #go through file sorting data for i in range(0, len(listOfDirs), 1): success = True try: fs = open(listOfDirs[i], "r") #print("Successfully opened "+directory) except: print("FAILED to open "+listOfDirs[i]) success = False if success == True: #read file for line in fs: cell = line.split(",") condData.append(functions.convert(float(cell[4]), volts, eSqH)) timeData.append(float(cell[3])) recursiveStepSearch(0, len(condData)-1, condData, timeData) steps = functions.removeDuplicates(steps) steps = functions.removeMinMaxValues(steps, max(condData)) if len(steps) == 0: numEmpty+=1 for item in steps: listOfBins[int(float(item+abs(minimum))/(binSize))] += 1 steps = [] condData = [] timeData =[] fs.close() print("Number of files where steps could not be detected: "+str(numEmpty)) #Estimate peaks baseAvg = functions.findBaselineAvg(listOfBins, numBins) peakData = functions.findpeaks(listOfBins, numBins, binSize, baseAvg) print("Calculating peaks...") peakXVal = [] for peak in peakData: peakXVal.append(peak*binSize) print("Peaks found at ") print(peakXVal) #write results to a file fs = open(outputFile, "w") j = 0 halfBin = binSize/2 for i in range(0, numBins, 1): try: if peakData[j] == i: fs.write((str((i*binSize)-abs(minimum)+halfBin))+","+str(listOfBins[i])+",20,"+str(baseAvg[i])+"\n") j+=1 else: fs.write((str((i*binSize)-abs(minimum)+halfBin))+","+str(listOfBins[i])+",0,"+str(baseAvg[i])+"\n") except: fs.write((str((i*binSize)-abs(minimum)+halfBin))+","+str(listOfBins[i])+",0,"+str(baseAvg[i])+"\n") print("Output File created.") fs.close()
def formHistogram(outputFile, listOfDirs): global maximum, minimum, numBins, volts, eSqH, binSize, listofBins, condData, timeData, stripSize, numSteps, steps, shifts, numEmpty listOfBins = functions.createZeroedList(numBins) print("Number of files opened: "+str(len(listOfDirs))) print("Min = "+str(minimum)+" Max = "+str(maximum)) binSize = (maximum-minimum)/(numBins-1) print("BinSize = "+str(binSize)) print("Finding steps...") #go through file sorting data for i in range(0, len(listOfDirs), 1): success = True try: fs = open(listOfDirs[i], "r") #print("Successfully opened "+directory) except: print("FAILED to open "+listOfDirs[i]) success = False if success == True: #read file Empty = True for line in fs: cell = line.split(",") condData.append(functions.convert(float(cell[4]), volts, eSqH) - shifts[i]) timeData.append(float(cell[3])) marker = 0 while marker < stripSize: steps = [] while marker < (2500-stripSize): stripDataX = [] stripDataY = [] for i in range (marker, marker+stripSize, 1): stripDataX.append(timeData[i]) stripDataY.append(condData[i]) b = functions.regressionFindB(stripDataX, stripDataY) sumY = 0 if abs(b) < 10000: # Fudge Factor numSteps += 1 for item in stripDataY: sumY += item sumY = sumY/stripSize steps.append(sumY) if len(steps) > 0: steps = functions.removeDuplicates(steps) steps = functions.removeMinMaxValues(steps, max(condData)) Empty = False marker += stripSize for item in steps: listOfBins[int(float(item+abs(minimum))/(binSize))] += 1 marker += 1 if Empty == True: numEmpty+=1 condData = [] timeData =[] fs.close() print("Number of files where steps could not be detected: "+str(numEmpty)) #Estimate peaks baseAvg = functions.findBaselineAvg(listOfBins, numBins) peakData = functions.findpeaks(listOfBins, numBins, binSize, baseAvg) print("Calculating peaks...") peakXVal = [] for peak in peakData: peakXVal.append(peak*binSize) print("Peaks found at ") print(peakXVal) #write results to a file fs = open(outputFile, "w") j = 0 halfBin = binSize/2 for i in range(0, numBins, 1): try: if peakData[j] == i: fs.write((str((i*binSize)-abs(minimum)+halfBin))+","+str(listOfBins[i])+",20,"+str(baseAvg[i])+"\n") j+=1 else: fs.write((str((i*binSize)-abs(minimum)+halfBin))+","+str(listOfBins[i])+",0,"+str(baseAvg[i])+"\n") except: fs.write((str((i*binSize)-abs(minimum)+halfBin))+","+str(listOfBins[i])+",0,"+str(baseAvg[i])+"\n") print("Output File created.") fs.close()
def formHistogram(outputFile, listOfDirs): valueList = [] stepListVoltageValues = [] fs = None z = 3 something = int(z / 3) j = 0 Top = 0 Bottom = 0 global numBins, volts, eSqH, binSize, listOfBins listOfBins = functions.createZeroedList(numBins) for count, directory in enumerate(listOfDirs): success = True try: fs = open(directory, "r") #print("Successfully opened "+directory) except: print("FAILED to open " + directory) success = False if success == True: valueList = [] for line in fs: cell = line.split(",") print(cell[4] + " " + str(float(cell[4]))) cell[4] = functions.convert(float(cell[4]), volts, eSqH) - shifts[count] if cell[4] > 0.3 and cell[4] < 14: valueList.append(float(cell[4])) for i in range(z, len(valueList), 1): #Start loop for at top value search Top = None if ((valueList[i] - valueList[i - something]) > ((valueList[i - something] - valueList[i - 2 * something]))): Bottom = None Top = valueList[i - something] j = i - something #store index for last value assessed for z in range( j, len(valueList), 1 ): #now carry on only looking for a much smaller increment size to give bottom of step if (((valueList[z] - valueList[z - something]) <= ((valueList[z - something] - valueList[z - 2 * something])) * (1 - 0))): Bottom = valueList[z] #store last index assessed break #break out of loop so we can calc the step try: if (((Top - Bottom) >= 0.2 * eSqH)): #filtering out the accidental mini steps stepListVoltageValues.append(Top) else: #print("false step between " + str(j) +"-" + str(i)) #explaining where we miscalc a step to then assess for debug print("nboithing") except: print("Nout") #minimum = min(stepListVoltageValues) #analyzing for the max and min range of step sizes, #maximum = max(stepListVoltageValues) binSize = (maximum - minimum) / ( numBins - 1 ) #To be done after data set has been full analyzed, so once while loop is ended print("min = " + str(minimum) + " max = " + str(maximum) + " BinSize = " + str(binSize)) print(functions.printList(stepListVoltageValues)) for i in range(0, len(stepListVoltageValues), 1): listOfBins[int( (stepListVoltageValues[i] - minimum) / binSize)] += 1 #print(int((stepListVoltageValues[i]-minimum)/binSize)) fs = open(outputFile, "w") #make the histo halfBin = binSize / 2 for i, item in enumerate(listOfBins): fs.write((str((i * binSize) + halfBin)) + "," + str(item) + "\n") print("Output File created.") fs.close()