def analyseVariousNDFs(topFolder): os.chdir(topFolder) ndfItems = os.listdir(".") NDFVals = [] print topFolder for ndfItem in ndfItems: if os.path.isdir(os.path.join(os.getcwd(), ndfItem)): NDFVals.append(ndfItem) print NDFVals dacValuesVarious = [] peaks = [] peaksErrors = [] widths = [] widthsErrors = [] areas = [] areasErrors = [] for ndfFolder in NDFVals: folders = [] ndfPath = os.path.join(os.getcwd(), ndfFolder, "dataset") items = os.listdir(ndfPath) for dacfolder in items: if os.path.isdir(os.path.join(ndfPath, dacfolder)) and is_number(dacfolder): folders.append(dacfolder) dacValues = [] peakValues = [] peakErrors = [] FWHMValues = [] FWHMErrors = [] areaValues = [] areaErrors = [] folders.sort(key=int) for dacFolder in folders: print "THIS IS DAC FOLDER: " + str(dacFolder) x, y = calc_utils.readTRCFiles(os.path.join(ndfPath, dacFolder), False) areaHisto, area, areaErr = root_utils.plot_area(x, y, "area") widthHisto, width, widthErr = root_utils.plot_width(x, y, "FWHM") peakHisto, meanPeak, peakErr = root_utils.plot_peak(x, y, "peak") #numSqrt = np.sqrt(len(os.listdir(os.path.join(ndfPath,dacFolder)))) peakValues.append(meanPeak) peakErrors.append(peakErr) FWHMValues.append(width) FWHMErrors.append(widthErr) areaValues.append(area) areaErrors.append(areaErr) dacValues.append(float(dacFolder)) dacValuesVarious.append(dacValues) peaks.append(peakValues) peaksErrors.append(peakErrors) areas.append(areaValues) areasErrors.append(areaErrors) return NDFVals, dacValuesVarious, peaks, peaksErrors, areas, areasErrors
def analyseVariousNDFs(topFolder): os.chdir(topFolder) ndfItems = os.listdir(".") NDFVals = [] print topFolder for ndfItem in ndfItems: if os.path.isdir(os.path.join(os.getcwd(),ndfItem)): NDFVals.append(ndfItem) print NDFVals dacValuesVarious = [] peaks = [] peaksErrors = [] widths =[] widthsErrors = [] areas = [] areasErrors = [] for ndfFolder in NDFVals: folders = [] ndfPath = os.path.join(os.getcwd(),ndfFolder,"dataset") items = os.listdir(ndfPath) for dacfolder in items: if os.path.isdir(os.path.join(ndfPath,dacfolder)) and is_number(dacfolder): folders.append(dacfolder) dacValues = [] peakValues = [] peakErrors = [] FWHMValues = [] FWHMErrors = [] areaValues = [] areaErrors = [] folders.sort(key=int) for dacFolder in folders: print "THIS IS DAC FOLDER: "+str(dacFolder) x,y = calc_utils.readTRCFiles(os.path.join(ndfPath,dacFolder),False) areaHisto, area, areaErr = root_utils.plot_area(x,y,"area") widthHisto, width, widthErr = root_utils.plot_width(x,y,"FWHM") peakHisto, meanPeak, peakErr = root_utils.plot_peak(x,y,"peak") #numSqrt = np.sqrt(len(os.listdir(os.path.join(ndfPath,dacFolder)))) peakValues.append(meanPeak) peakErrors.append(peakErr) FWHMValues.append(width) FWHMErrors.append(widthErr) areaValues.append(area) areaErrors.append(areaErr) dacValues.append(float(dacFolder)) dacValuesVarious.append(dacValues) peaks.append(peakValues) peaksErrors.append(peakErrors) areas.append(areaValues) areasErrors.append(areaErrors) return NDFVals,dacValuesVarious,peaks,peaksErrors,areas,areasErrors
areaValues = [] areaErrors = [] topFolder = sys.argv[1] os.chdir(topFolder) items = os.listdir(".") folders = [] for freqfolder in items: if os.path.isdir(freqfolder) and is_number(freqfolder[:-3]): print freqfolder[:-3] folders.append(freqfolder) folders = sorted(folders, key=lambda x: int(x[:-2])) print folders for freqFolder in folders: print "THIS IS FREQ FOLDER: " + str(freqFolder) x, y = calc_utils.readTRCFiles(freqFolder, False) output = ROOT.TFile(freqFolder + ".root", "recreate") areaHisto, area, areaErr = root_utils.plot_area(x, y, "area") widthHisto, width, widthErr = root_utils.plot_width(x, y, "FWHM") peakHisto, meanPeak, peakErr = root_utils.plot_peak(x, y, "peak") numSqrt = np.sqrt(len(os.listdir(freqFolder))) areaHisto.Write() widthHisto.Write() peakHisto.Write() output.Close() peakValues.append(meanPeak) peakErrors.append(peakErr / numSqrt) FWHMValues.append(width) FWHMErrors.append(widthErr / numSqrt) areaValues.append(area) areaErrors.append(areaErr / numSqrt)
import root_utils import calc_utils import os import sys import ROOT import matplotlib.pyplot as plt import numpy as np x,y = calc_utils.readTRCFiles(os.path.join(sys.argv[1]),correct_offset=False) histo = ROOT.TH1D("amp histo","amp histo",100,-0.05,0.05) output = ROOT.TFile("amplitudeHisto.root","recreate") ymean = np.mean(y,0) for i in range(len(x)): print str(x[i])+" "+str(y[0][i]) for i in range(len(y)): plt.plot(x,y[i]) for i in range(len(y)): for j in range(len(x)): histo.Fill(y[i][j]) plt.show() plt.figure(1) plt.plot(x,ymean) plt.show() print "MEAN VALUE IS: "+str(np.mean(ymean)) histo.Write() output.Close()
areaValues = [] areaErrors = [] areaFWHM = [] topFolder = sys.argv[1] os.chdir(topFolder) items = os.listdir(".") folders = [] for dacfolder in items: if os.path.isdir(dacfolder) and is_number(dacfolder): folders.append(dacfolder) folders.sort(key=int) print folders for dacFolder in folders: print "THIS IS DAC FOLDER: "+str(dacFolder) x,y = calc_utils.readTRCFiles(dacFolder,False) output = ROOT.TFile(dacFolder+".root","recreate") areaHisto,photonHisto, area, areaErr,areaErrOnMean = root_utils.plot_area(x,y,"area",lower_limit=9.e-8,upper_limit=9.e-8) widthHisto, width, widthErr, widthErrOnMean = root_utils.plot_width(x,y,"FWHM") peakHisto, meanPeak, peakErr, peakErrOnMean = root_utils.plot_peak(x,y,"peak") #numSqrt = np.sqrt(len(os.listdir(dacFolder))) photonHisto.Write() areaHisto.Write() widthHisto.Write() peakHisto.Write() output.Close() peakValues.append(meanPeak) peakErrors.append(peakErrOnMean) FWHMValues.append(width) FWHMErrors.append(widthErrOnMean) areaValues.append(area)
import root_utils import calc_utils import os import sys import ROOT import matplotlib.pyplot as plt import numpy as np x, y = calc_utils.readTRCFiles(os.path.join(sys.argv[1]), correct_offset=False) histo = ROOT.TH1D("amp histo", "amp histo", 100, -0.05, 0.05) output = ROOT.TFile("amplitudeHisto.root", "recreate") ymean = np.mean(y, 0) for i in range(len(x)): print str(x[i]) + " " + str(y[0][i]) for i in range(len(y)): plt.plot(x, y[i]) for i in range(len(y)): for j in range(len(x)): histo.Fill(y[i][j]) plt.show() plt.figure(1) plt.plot(x, ymean) plt.show() print "MEAN VALUE IS: " + str(np.mean(ymean)) histo.Write() output.Close()
areaValues = [] areaErrors = [] topFolder = sys.argv[1] os.chdir(topFolder) items = os.listdir(".") folders = [] for freqfolder in items: if os.path.isdir(freqfolder) and is_number(freqfolder[:-3]): print freqfolder[:-3] folders.append(freqfolder) folders = sorted(folders,key=lambda x:int(x[:-2])) print folders for freqFolder in folders: print "THIS IS FREQ FOLDER: "+str(freqFolder) x,y = calc_utils.readTRCFiles(freqFolder,False) output = ROOT.TFile(freqFolder+".root","recreate") areaHisto, area, areaErr = root_utils.plot_area(x,y,"area") widthHisto, width, widthErr = root_utils.plot_width(x,y,"FWHM") peakHisto, meanPeak, peakErr = root_utils.plot_peak(x,y,"peak") numSqrt = np.sqrt(len(os.listdir(freqFolder))) areaHisto.Write() widthHisto.Write() peakHisto.Write() output.Close() peakValues.append(meanPeak) peakErrors.append(peakErr/numSqrt) FWHMValues.append(width) FWHMErrors.append(widthErr/numSqrt) areaValues.append(area) areaErrors.append(areaErr/numSqrt)
areaValues = [] areaErrors = [] areaFWHM = [] topFolder = sys.argv[1] os.chdir(topFolder) items = os.listdir(".") folders = [] for dacfolder in items: if os.path.isdir(dacfolder) and is_number(dacfolder): folders.append(dacfolder) folders.sort(key=int) print folders for dacFolder in folders: print "THIS IS DAC FOLDER: " + str(dacFolder) x, y = calc_utils.readTRCFiles(dacFolder, False) output = ROOT.TFile(dacFolder + ".root", "recreate") areaHisto, photonHisto, area, areaErr, areaErrOnMean = root_utils.plot_area( x, y, "area", lower_limit=9.e-8, upper_limit=9.e-8) widthHisto, width, widthErr, widthErrOnMean = root_utils.plot_width( x, y, "FWHM") peakHisto, meanPeak, peakErr, peakErrOnMean = root_utils.plot_peak( x, y, "peak") #numSqrt = np.sqrt(len(os.listdir(dacFolder))) photonHisto.Write() areaHisto.Write() widthHisto.Write() peakHisto.Write() output.Close() peakValues.append(meanPeak) peakErrors.append(peakErrOnMean)