def display(self,item): self.currentFile=self.listShots.currentItem().text() signal1=self.signalChoice1.currentText() signal2=self.signalChoice2.currentText() time1,data1,sampling1=readHdf5.getData(self.currentFile,signal1,self.env) time2,data2,sampling2=readHdf5.getData(self.currentFile,signal2,self.env) if sampling2>=sampling1: self.data2=interp1d(time2,data2)(time1) self.timei=time1 self.data1=data1 else: self.data1=interp1d(time1,data1)(time2) self.timei=time2 self.data2=data2 self.p1.clear() self.p1.plot(self.timei,data1) self.p2.clear() self.p2.plot(self.timei,self.data2) #self.p2.linkXAxis(self.p1) self.lr1=pg.LinearRegionItem([self.timei[0],self.timei[-1]]) self.lr1.setZValue(-10) self.lr2=pg.LinearRegionItem([self.timei[0],self.timei[-1]]) self.lr2.setZValue(-10) self.p1.addItem(self.lr1) self.p2.addItem(self.lr2) self.lr1.sigRegionChanged.connect(self.updatePlot1) self.lr2.sigRegionChanged.connect(self.updatePlot2)
def plotSignal(self,item): indexColor=0 self.p1.clear() self.p2.clear() for fileName in self.fileName: print fileName self.Back=False self.signalName=item time,data,self.sampling=readHdf5.getData(fileName,item,self.env) self.time=np.array(time) self.data=np.array(data) self.frqlabel.setText('sampling rate: '+str(self.sampling)) pencil=pg.mkPen(color=pg.intColor(indexColor)) self.p1.plot(self.time,self.data,pen=pencil) self.p2.plot(self.time,self.data,pen=pencil) indexColor=indexColor+1 if self.existingData: self.lr=pg.LinearRegionItem([self.left,self.right]) else: self.lr=pg.LinearRegionItem([self.time[0],self.time[-1]]) self.left=self.time[0] self.right=self.time[-1] self.lr.setZValue(-10) self.p1.addItem(self.lr) self.lr.sigRegionChanged.connect(self.updatePlot)
def __init__(self,filename,env,parent=None): super(positionARM,self).__init__(parent) pg.setConfigOption('background', 'w') pg.setConfigOption('foreground', 'k') self.fileName=filename[0] self.setWindowTitle("Correlate attributes") #self.resize(1000,1000) self.env=env view=pg.PlotWidget() item='PXI M6251/manip_pos' time,data,self.sampling=readHdf5.getData(self.fileName,item,self.env) data=self.movingaverage(data,5000) view.plot(time,data) vbox1=QtGui.QVBoxLayout() vbox1.addStretch(1) vbox1.addWidget(view) self.setLayout(vbox1) self.show()
def get(self): # self.write('List of discharges\n') # # conn=sqlite3.connect('ishtar') # curs=conn.cursor() # curs.execute('select * from shots') # for row,form in enumerate(curs): # for column, item in enumerate(form): # #print str(item) # self.write(str(item)+'\n') env=Environment() time,data,sampling=readHdf5.getData('00857_Data','Generator/Fpower',env) #print time[100],data[100] plot = figure() plot.line(np.array(time), np.array(data)) html = file_html(plot, CDN, "my plot") self.write(html)
def calculate(self): self.results=dict() #item=self.signalChoice.currentText() for file in self.fileName: for item in self.env.getSignals(): try: print item time,data,self.sampling=readHdf5.getData(file,item,self.env) rang=self.p2.getPlotItem().getViewBox().viewRange() rang2=rang[0] average=np.mean(data[(time>=rang2[0]) & (time<=rang2[1])]) maxi=np.max(data[(time>=rang2[0]) & (time<=rang2[1])]) mini=np.min(data[(time>=rang2[0]) & (time<=rang2[1])]) # self.results[file]=[average,maxi,mini] # self.textResult.append(file+':\n'+'Mean: '+str(average)+'\n'+'Max: '+str(maxi)+'\n'+'Min: '+str(mini)+'\n') nameAttr=self.env.attr(item)+self.attribut.text() readHdf5.saveAttr(file,nameAttr,np.array([average,maxi,mini]),self.env) except: pass pickle.dump([self.left,self.right,self.attribut.text(),self.signalChoice.currentText()], open( "User.dat", "wb" ) )
def calculatefft(self): indexColor=0 self.p3.clear() self.p3.addLegend() for fileName in self.fileName: time,data,self.sampling=readHdf5.getData(fileName,self.signalName,self.env) self.time=np.array(time) self.data=np.array(data) rang=self.p2.getPlotItem().getViewBox().viewRange() rang2=rang[0] # Number of samplepoints dataslice=self.data[(self.time>=rang2[0]) & (self.time<=rang2[1])] N=len(dataslice) # sample spacing T = 1.0 / self.sampling yf = scipy.fftpack.fft(dataslice) xf = np.linspace(0.0, 1.0/(2.0*T), N/2) pencil=pg.mkPen(color=pg.intColor(indexColor)) self.p3.plot(xf, 2.0/N * np.abs(yf[0:N/2]),pen=pencil,name=fileName[0:-5]) indexColor=indexColor+1 self.p3.setLabel('left', "Spectral power (SI)") self.p3.setLabel('bottom', "Frequency (Hz)")
def __init__(self,filename,env,parent=None): super(overview,self).__init__(parent) pg.setConfigOption('background', 'w') pg.setConfigOption('foreground', 'k') self.fileName=filename self.setWindowTitle("Overview Signal") self.showMaximized() self.env=env p1=self.addPlot(title='Current Big coils') self.nextRow() p2=self.addPlot(title='Pressure') self.nextRow() p3=self.addPlot(title='Helicon power') self.nextRow() p4=self.addPlot(title='ICRF power') self.nextRow() p5=self.addPlot(title='Density Langmuir probe') self.nextRow() p6=self.addPlot(title='Amplitude B-dot probes') self.nextRow() p7=self.addPlot(title='Phase B-dot probes') indexColor=0 for x in self.fileName: try: timeCoils,dataCoils,sampling=readHdf5.getData(x,'S7/Big_coil_I [A]',env) except: pass try: timeP,dataP,sampling=readHdf5.getData(x,'S7/vacuum [mbar]',env) except: pass try: timeHF,dataHF,sampling=readHdf5.getData(x,'Generator/Fpower',env) except: pass try: timeHR,dataHR,sampling=readHdf5.getData(x,'Generator/Rpower',env) except: pass try: timeIF,dataIF,sampling=readHdf5.getData(x,'PXI M6251/IC_fwd',env) except: pass try: timeIR,dataIR,sampling=readHdf5.getData(x,'PXI M6251/IC_ref',env) except: pass try: dataL=np.array(readHdf5.getDataProcess(x,'Process/Langmuir_dens',env)) timeL=np.array(readHdf5.getDataProcess(x,'Process/Langmuir_time',env)) except: pass try: timeFW,dataFW,sampling=readHdf5.getData(x,'PXI M6251/U_fast',env) except: pass try: timeSW,dataSW,sampling=readHdf5.getData(x,'PXI M6251/U_slow',env) except: pass try: timePhase1,dataPhase1,sampling=readHdf5.getData(x,'PXI M6251/Phi_fast',env) except: pass try: timePhase2,dataPhase2,sampling=readHdf5.getData(x,'PXI M6251/Phi_slow',env) except: pass pencil=pg.mkPen(color=pg.intColor(indexColor)) try: p1.plot(timeCoils,dataCoils,pen=pencil) except: pass try: p2.plot(timeP,dataP,pen=pencil) except: pass try: p3.plot(timeHF,dataHF,pen=pencil) p3.plot(timeHR,dataHR,pen=pencil) except: pass try: p4.plot(timeIF,dataIF,pen=pencil) p4.plot(timeIR,dataIR,pen=pencil) except: pass try: p5.plot(timeL,dataL,pen=pencil) except: pass try: p6.plot(timeFW,dataFW,pen=pencil) p6.plot(timeSW,dataSW,pen=pencil) except: pass try: p7.plot(timePhase1,dataPhase1-dataPhase2,pen=pencil) except: pass indexColor=indexColor+1 p7.setXLink(p1) p6.setXLink(p1) p5.setXLink(p1) p4.setXLink(p1) p3.setXLink(p1) p2.setXLink(p1)