def addMagneticField(): path=r"D:"+os.sep+"DATA"+os.sep+"Acquired_data" env=Environment() listeFiles=[] for file in os.listdir(path): if file.endswith(".h5"): listeFiles.append(file[0:-3]) for file in listeFiles: try: readHdf5.saveAttr(file,'date',timei,env) except: print file+'.tdms not found'
def saveAttr(self): attr=self.saveL.text() readHdf5.saveAttr(self.fileName,attr,np.array([self.T,self.dens,self.Vfloat,self.Vplasma]),self.env) sig1=self.signalChoice1.currentText() sig2=self.signalChoice2.currentText() lsample=self.text1.text() gasindex=self.gas.currentIndex() temp=self.temp.text() calculate=self.tempChoice.isChecked() pickle.dump([sig1,sig2,self.l1,self.r1,self.l2,self.r2,self.l3,self.r3,lsample,gasindex,calculate,temp] , open( "UserLangmuir.dat", "wb" ) ) self.env.process.updateShot([self.fileName])
def addDate(): path=r"D:"+os.sep+"DATA"+os.sep+"Acquired_data" env=Environment() listeFiles=[] for file in os.listdir(path): if file.endswith(".h5"): listeFiles.append(file[0:-3]) for file in listeFiles: try: timei=time.ctime(os.path.getmtime(path+os.sep+file+'.tdms')) readHdf5.saveAttr(file,'date',timei,env) except: print file+'.tdms not found'
def addWincc(): path=r"D:"+os.sep+"DATA"+os.sep+"Acquired_data" env=Environment() listeFiles=[] for file in os.listdir(path): #print file[0:2] if file.endswith(".csv") and file[0:2]=='Is': #listeFiles.append(file[0:-3]) inputfile=open(path+os.sep+file) #inputfile.next() print inputfile.readline() #timei=datetime.datetime.strptime(inputfile.readline()[13:-1],'%d.%m.%Y %H:%M:%S') timei=inputfile.readline()[13:-1] print timei h5file='0'+file[7:-4]+'_Data' print h5file readHdf5.saveAttr(h5file,'date',timei,env)
def convert_csv(fileName,tempo,env): path=env.path if tempo: time.sleep(2) try: inputfile=open(path+os.sep+fileName+'.csv') #inputfile.next() print inputfile.readline() #timei=datetime.datetime.strptime(inputfile.readline()[13:-1],'%d.%m.%Y %H:%M:%S') timei=inputfile.readline()[13:-1] #print timei h5file=fileName[7:].zfill(5)+'_Data' #print h5file readHdf5.saveAttr(h5file,'date',timei,env) #print h5file env.process.updateShot([h5file]) except: print "Doesn't work"
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" ) )
class Environment(): def __init__(self): self.path=r"D:"+os.sep+"ISHTARmay" def calibr(x): slope=(76.-23.)/(400.-1400.) return (x-400.)*slope+76.-33 listePositionspace=[] for x in listePosition: listePositionspace.append(calibr(x)) i=0 env=Environment() while i<len(listeShots): fileName='00'+str(listeShots[i])+'_Data' print listeShots[i] Attrname='position' value=listePosition[i] readHdf5.saveAttr(fileName,Attrname,value,env) Attrname='positionspace' value=listePositionspace[i] i=i+1