diff --git a/Analyse/ana.py b/Analyse/ana.py index 2615c75..7467e40 100644 --- a/Analyse/ana.py +++ b/Analyse/ana.py @@ -3,6 +3,74 @@ import math from ROOT import TH1D, TH2D, TCanvas, TGraph, TLine from array import array +''' +def CanvasPartition(C, Nx, Ny, + lMargin, rMargin, + bMargin, tMargin): + if (!C): + return + # Setup Pad layout: + vSpacing = 0.0 + vStep = (1.- bMargin - tMargin - (Ny-1) * vSpacing) / Ny + hSpacing = 0.0 + hStep = (1.- lMargin - rMargin - (Nx-1) * hSpacing) / Nx + vposd,vposu,vmard,vmaru,vfactor + hposl,hposr,hmarl,hmarr,hfactor + for i in xrange( 0, Nx): + if (i==0): + hposl = 0.0 + hposr = lMargin + hStep + hfactor = hposr-hposl + hmarl = lMargin / hfactor + hmarr = 0.0 + else if (i == Nx-1): + hposl = hposr + hSpacing + hposr = hposl + hStep + rMargin + hfactor = hposr-hposl + hmarl = 0.0 + hmarr = rMargin / (hposr-hposl) + else: + hposl = hposr + hSpacing + hposr = hposl + hStep + hfactor = hposr-hposl + hmarl = 0.0 + hmarr = 0.0 + + for j in xrange(0,Ny): + if (j==0): + vposd = 0.0 + vposu = bMargin + vStep + vfactor = vposu-vposd + vmard = bMargin / vfactor + vmaru = 0.0 + else if (j == Ny-1): + vposd = vposu + vSpacing + vposu = vposd + vStep + tMargin + vfactor = vposu-vposd + vmard = 0.0 + vmaru = tMargin / (vposu-vposd) + else: + vposd = vposu + vSpacing + vposu = vposd + vStep + vfactor = vposu-vposd + vmard = 0.0 + vmaru = 0.0 + + C.cd(0) + + pad = new TPad(string(i)+strting(j),"",hposl,vposd,hposr,vposu) + pad.SetLeftMargin(hmarl) + pad.SetRightMargin(hmarr) + pad.SetBottomMargin(vmard) + pad.SetTopMargin(vmaru) + pad.SetFrameBorderMode(0) + pad.SetBorderMode(0) + pad.SetBorderSize(0) + pad.Draw() +''' + + + def RMS(arr): @@ -44,7 +112,7 @@ self.data=data - def read(self,scope, temperature, sig): + def read(self,scope, temperature, sig, n_samples): print 'Reading the data from Scope: ', scope, "temprature: ", temperature, "Signal/noise: ", sig data_file="data/" if(scope == "TL"): @@ -58,6 +126,14 @@ print data_file print chan + counter=0 + + RMS1=[] + RMS2=[] + RMS3=[] + V1=[] + V2=[] + V3=[] if(scope == "RS"): for filename in os.listdir(data_file): @@ -67,7 +143,7 @@ print filename if(filename=="INDEX.CSV"): continue - + counter+=1 with open(data_file+"/"+filename, 'r') as file: data_csv=csv.reader(file, delimiter=',') @@ -77,21 +153,34 @@ if(first): first=False continue - time.append(float(row[0])*1.e6) + time.append(float(row[0])*1.e9) #print chan[0] #print row V_tmp=[] for c in xrange(1,5): if(c != chan[0]): V_tmp.append(float(row[c])) - print 'Appendet channel ', c + #print 'Appendet channel ', c V.append(V_tmp) V_trig.append(float(row[chan[0]])) ana=Analysis(time,V,V_trig) f_out=filename f_out=f_out.replace("CSV", "pdf") - int1,int2,int3=ana.ana(f_out) + v1,v2,v3,rms1,rms2,rms3=ana.ana(f_out) + V1.append(v1) + V2.append(v2) + V3.append(v3) + RMS1.append(rms1) + RMS2.append(rms2) + RMS3.append(rms3) + + if(counter>=n_samples): + break + + + return RMS1, RMS2, RMS3, V1, V2, V3 + def get_dir(self,scope,temperature, sig): ret=[] t_chan=[] @@ -118,9 +207,9 @@ lenght=len(self.time) for i in xrange(0,lenght): t.append(self.time[i]) - c1.append(self.V[i][0]) - c2.append(self.V[i][1]) - c3.append(self.V[i][2]) + c1.append(self.V[i][0]*1.e3) + c2.append(self.V[i][1]*1.e3) + c3.append(self.V[i][2]*1.e3) c_trig.append(self.V_trig[i]) if(float(self.time[i])*1e9<-20.): t0=t0+1 @@ -130,32 +219,45 @@ mean_V1=mean(c1[0:t0]) c1=correct_mean(c1,mean_V1) rms_v1=RMS(c1[0:t0]) + gr1.SetTitle("Channel 1") + gr1.GetXaxis().SetTitle("t [ns]") + gr1.GetYaxis().SetTitle("U [mV]") + gr2 = TGraph( lenght, t, c2 ) mean_V2=mean(c2[0:t0]) c2=correct_mean(c2,mean_V2) rms_v2=RMS(c2[0:t0]) - + gr2.SetTitle("Channel 2") + gr2.GetXaxis().SetTitle("t [ns]") + gr2.GetYaxis().SetTitle("U [mV]") + gr3 = TGraph( lenght, t, c3 ) mean_V3=mean(c3[0:t0]) c3=correct_mean(c3,mean_V3) rms_v3=RMS(c3[0:t0]) - + gr3.SetTitle("Channel 3") + gr3.GetXaxis().SetTitle("t [ns]") + gr3.GetYaxis().SetTitle("U [mV]") + gr_trig = TGraph( lenght, t, c_trig ) mean_trig=mean(c_trig[0:t0]) c_trig=correct_mean(c_trig,mean_trig) rms_trig=RMS(c_trig[0:t0]) - - n=len(t) + gr_trig.SetTitle("Triggering Channel") + gr_trig.GetXaxis().SetTitle("t [ns]") + gr_trig.GetYaxis().SetTitle("U [mV]") + n=len(t) + ''' gr1 = TGraph( n, t, c1 ) gr2 = TGraph( n, t, c2 ) gr3 = TGraph( n, t, c3 ) gr_trig = TGraph( n, t, c_trig ) - + ''' if(out): can1=TCanvas("c1", "c1",1920,1080) - can1.Divide(2,2,0,0) + can1.Divide(2,2,0.01,0.01) can1.cd(1) gr1.Draw() can1.cd(2) @@ -172,4 +274,5 @@ integral3=integral(t,c3) - return integral1, integral2, integral3 + return max(c1), max(c2), max(c3), rms_v1, rms_v2, rms_v3 + diff --git a/Analyse/data_corrected.py b/Analyse/data_corrected.py new file mode 100644 index 0000000..7dcc886 --- /dev/null +++ b/Analyse/data_corrected.py @@ -0,0 +1,547 @@ + + +dict_data=[ + + # temperature -20 + { + "scope" : "RS", + "temperature" : -20, + "vcc" : 56, + "dir" : 'WFM14', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "TL", + "temperature" : -20, + "vcc" : 56, + "dir" : 'pk2', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "TL", + "temperature" : -20, + "vcc" : 56, + "dir" : 'pk3/pk3t', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + { + "scope" : "RS", + "temperature" : -20, + "vcc" : 56, + "dir" : 'WFM15', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + + +# temperature -17 + { + "scope" : "RS", + "temperature" : -17, + "vcc" : 56, + "dir" : 'WFM16', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "TL", + "temperature" : -17, + "vcc" : 56, + "dir" : 'pk5/pk5t', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "TL", + "temperature" : -17, + "vcc" : 56, + "dir" : 'pk6/pk6t', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + { + "scope" : "RS", + "temperature" : -17, + "vcc" : 56, + "dir" : 'WFM17', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, +# temperature -14 + { + "scope" : "RS", + "temperature" : -14, + "vcc" : 56, + "dir" : 'WFM18', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "TL", + "temperature" : -14, + "vcc" : 56, + "dir" : 'pk7/pk7t', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "TL", + "temperature" : -14, + "vcc" : 56, + "dir" : 'pk8/pk8t', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, +{ + "scope" : "RS", + "temperature" : -14, + "vcc" : 56, + "dir" : 'WFM19', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + # temperature -11 + { + "scope" : "TL", + "temperature" : -11, + "vcc" : 56, + "dir" : 'pk10/pk10t', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : -11, + "vcc" : 56, + "dir" : 'WFM20', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : -11, + "vcc" : 56, + "dir" : 'WFM21', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + { + "scope" : "TL", + "temperature" : -11, + "vcc" : 56, + "dir" : 'pk11/pk11t', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + # temperature -8 + { + "scope" : "TL", + "temperature" : -8, + "vcc" : 56, + "dir" : 'pk13/pk13t', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : -8, + "vcc" : 56, + "dir" : 'WFM22', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : -8, + "vcc" : 56, + "dir" : 'WFM23', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + { + "scope" : "TL", + "temperature" : -8, + "vcc" : 56, + "dir" : 'pk14/pk14t', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + # temperature -5.5 + { + "scope" : "TL", + "temperature" : -5.5, + "vcc" : 56, + "dir" : 'pk16/pk16t', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : -5.5, + "vcc" : 56, + "dir" : 'WFM24', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : -5.5, + "vcc" : 56, + "dir" : 'WFM25', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + { + "scope" : "TL", + "temperature" : -5.5, + "vcc" : 56, + "dir" : 'pk17/pk17t', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + # temperature -2 + { + "scope" : "TL", + "temperature" : -2, + "vcc" : 56, + "dir" : 'pk18/pk18t', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : -2, + "vcc" : 56, + "dir" : 'WFM26', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : -2, + "vcc" : 56, + "dir" : 'WFM27', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + { + "scope" : "TL", + "temperature" : -2, + "vcc" : 56, + "dir" : 'pk19/pk19t', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + # temperature 0 + { + "scope" : "TL", + "temperature" : -1, + "vcc" : 56, + "dir" : 'pk20', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : 0, + "vcc" : 56, + "dir" : 'WFM28', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : 0, + "vcc" : 56, + "dir" : 'WFM29', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + { + "scope" : "TL", + "temperature" : 0, + "vcc" : 56, + "dir" : 'pk21', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + # temperature 2 + { + "scope" : "TL", + "temperature" : 2, + "vcc" : 56, + "dir" : 'pk23', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : 2, + "vcc" : 56, + "dir" : 'WFM30', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : 2, + "vcc" : 56, + "dir" : 'WFM31', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + { + "scope" : "TL", + "temperature" : 2, + "vcc" : 56, + "dir" : 'pk22', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + # temperature 2 + { + "scope" : "TL", + "temperature" : 5, + "vcc" : 56, + "dir" : 'pk24', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : 5, + "vcc" : 56, + "dir" : 'WFM32', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : 5, + "vcc" : 56, + "dir" : 'WFM33', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + { + "scope" : "TL", + "temperature" : 5, + "vcc" : 56, + "dir" : 'pk25', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + + # temperature 7.5 + { + "scope" : "TL", + "temperature" : 7.5, + "vcc" : 56, + "dir" : 'pk26', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : 7.5, + "vcc" : 56, + "dir" : 'WFM34', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : 7.5, + "vcc" : 56, + "dir" : 'WFM35', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + { + "scope" : "TL", + "temperature" : 7.5, + "vcc" : 56, + "dir" : 'pk27', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + # temperature 11 + { + "scope" : "TL", + "temperature" : 11, + "vcc" : 56, + "dir" : 'pk28', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : 11, + "vcc" : 56, + "dir" : 'WFM36', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : 11, + "vcc" : 56, + "dir" : 'WFM37', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + { + "scope" : "TL", + "temperature" : 11, + "vcc" : 56, + "dir" : 'pk29', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + # temperature 14 + { + "scope" : "TL", + "temperature" : 11, + "vcc" : 56, + "dir" : 'pk30', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : 11, + "vcc" : 56, + "dir" : 'WFM38', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "sig", + "div" : 20 + }, + { + "scope" : "RS", + "temperature" : 11, + "vcc" : 56, + "dir" : 'WFM39', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + }, + { + "scope" : "TL", + "temperature" : 11, + "vcc" : 56, + "dir" : 'pk31', + "trig_channel" : 1, + "trig_vcc" : -6, + "type" : "noise", + "div" : 2 + } +] + + + + + + diff --git a/Analyse/main.py b/Analyse/main.py index 82ce353..e39a1b8 100644 --- a/Analyse/main.py +++ b/Analyse/main.py @@ -6,7 +6,7 @@ import math import sys -from data import dict_data +from data_corrected import dict_data from ana import Reader @@ -15,11 +15,28 @@ print 'Software to analysis Cooling results for Magnet Stations' print 'Author: Jihyun Bhom' - reader=Reader(dict_data) - reader.read("RS", -17, "noise") - - + scope="RS" + RMS_noise=[] + V_signal=[] + temperature=[] + + for i in dict_data: + if((i["scope"]==scope)): + temp=i["temperature"] + + for j in ["noise", "sig"]: + + reader=Reader(dict_data) + RMS1, RMS2, RMS3, V1, V2, V3=reader.read("RS", temp, j ,20) + + if(j=="noise"): + RMS_noise.append(RMS1) + + + + + if __name__ == "__main__": sys.exit(main(sys.argv))