Beispiel #1
0
    def updateKnots(self):

        min = self.plot.knots[0].getPosition()
        max = self.plot.knots[-1].getPosition()

        kmin = calc.toKSpace(min, self.E0)
        kmax = calc.toKSpace(max, self.E0)

        self.plot.resetPlot()
        size = self.spinBoxes.spinBox1.value()

        div = (kmax - kmin) / (size - 1)

        self.plot.addKnot(min)
        self.plot.addBoundsExceptions(0, 0, self.E0)

        for i in range(1, size - 1):
            temp = calc.fromKSpace(kmin + i * div, self.E0)
            temp2 = calc.getClosest(temp, self.xdata)
            self.plot.addKnot(temp2)

        self.plot.addKnot(max)

        # self.normCurve=self.plot.insertCurve("norm")
        self.plot.setCurvePen(self.normCurve, QPen(QColor(Qt.black), 2))

        # self.splineCurve=self.plot.insertCurve("spline")
        self.plot.setCurvePen(self.splineCurve, QPen(QColor(Qt.darkGreen), 2))

        self.updatePlot()
Beispiel #2
0
 def updateXAFSPlot(self):
     
     self.kspace.clearFixedKnots()
     
     normknots=self.norm.plot.knots
     
     for knot in normknots[:-1]:
         
         pos=knot.getPosition()
         kpos=calc.toKSpace(pos,self.E0)
         self.kspace.addFixedKnot(kpos)
         
     pos=normknots[-1].getPosition()
     kpos=calc.toKSpace(pos,self.E0)
     self.kspace.addFixedKnot(kpos)
     
     xdata=self.raw.xdata
     normdata=self.norm.normdata
     splinedata=self.norm.splinedata
     
     #generate kdata
     kdata=[]
     for x in xdata:
         kdata.append(calc.toKSpace(x,self.E0))
     
     
     k0index=0
     while(xdata[k0index]<self.E0):
         k0index+=1
     
     xafsdata=calc.calcXAFS(normdata[k0index:],splinedata[k0index:],kdata[k0index:])
     self.kspace.setXAFSData(kdata[k0index:],xafsdata)
     
     self.updateFFTPlot()
Beispiel #3
0
    def editParameters(self):
        edgeDialog=EdgeDialog()
        edgeDialog.slotCheckBoxToggled(True)
        edgeDialog.checkBox1.setChecked(True)
        edgeDialog.setTitle(self.title)
        edgeDialog.setValue(self.E0)
        
        result=edgeDialog.exec_loop()
        
        if(result==QDialog.Rejected):
            return
            
        self.E0=edgeDialog.getValue()
        self.title=edgeDialog.getTitle()
        
        xdata=self.raw.xdata
        
        #check to see if E0 is reasonable!!
        while((self.E0 < xdata[0]) or (self.E0 > xdata[-1])):
            #for some reason, in windows, the str version used wasn't the
            #builtin version to convert between numbers and strings
            errstr="There appears to be a problem with E0="+__builtins__.str(self.E0)+". This value does not fall in the range of your data."
            QMessageBox.critical(self,QString("Error with E0"),QString(errstr))

            result=edgeDialog.exec_loop()
            if(result==QDialog.Rejected):
                return
                
        self.E0=edgeDialog.getValue()
        self.title=edgeDialog.getTitle()
        self.norm.plot.addBoundsExceptions(0,0,self.E0)
        pos=calc.getClosest(self.E0,xdata)
        self.norm.plot.knots[0].setPosition(pos)
        
        kmax=calc.toKSpace(xdata[-1],self.E0)
        kmin=calc.toKSpace(pos,self.E0)
        self.kspace.plot.resetPlot()
        
        self.setupXAFSPlot(kmax,kmin,kmax)
        
        #self.kdata,self.k0index=self.calcKSpace(self.xdata)
        self.updateNormPlot()
Beispiel #4
0
    def fileImport(self):

        xdata=[]
        ydata=[]
        i0data=[]
        
        filename=QFileDialog.getOpenFileName(QString.null,QString("*.dat;;*"))
        self.filename=filename.latin1()
        if self.filename == None:
            return
            
        file=open(filename.latin1())
        
        line=file.readline()
        while(line):
            array=string.split(line)
            
            #assume ev k i0 raw
            if(len(array)==4):
                xdata.append(float(array[0]))
                i0data.append(float(array[2]))
                ydata.append(float(array[3]))
            
            #assume ev k
            else:
                xdata.append(float(array[0]))
                ydata.append(float(array[1]))
                i0data.append(0.0)
                
            line=file.readline()
        
        file.close()
        
        edgeDialog=EdgeDialog()
        result=edgeDialog.exec_loop()
        
        if(result==QDialog.Rejected):
            return
            
        self.E0=edgeDialog.getValue()
        self.title=edgeDialog.getTitle()
        
        #check to see if E0 is reasonable!!
        while((self.E0 < xdata[0]) or (self.E0 > xdata[-1])):
            #for some reason, in windows, the str version used wasn't the
            #builtin version to convert between numbers and strings
            errstr="There appears to be a problem with E0="+str(self.E0)+". This value does not fall in the range of your data."
            QMessageBox.critical(self,QString("Error with E0"),QString(errstr))

            result=edgeDialog.exec_loop()
            
            if(result==QDialog.Rejected):
                return
                
            self.E0=edgeDialog.getValue()
            self.title=edgeDialog.getTitle()
                
        self.resetPlots()
        self.setupRawPlot(xdata,ydata,xdata[0],xdata[-1],2)
        self.setupNormPlot(xdata,[self.E0,xdata[-1]],[2])
        self.i0.setI0Data(xdata,i0data)
        
        kmax=calc.toKSpace(xdata[-1],self.E0)
        self.setupXAFSPlot(kmax,0,kmax)
        
        self.raw.updatePlot()
Beispiel #5
0
    def fileStringOpen(self,str):
        
        if str == None:
            return
        
        self.filename=str
        file=open(str)
        
#check to see if it has a title
        line=file.readline()
        if(line[:5]=='TITLE'):
            self.title=line[6:-1]
            line=file.readline()
            
#check to see if line is a comment
        while(line[0]=='#'):
            self.comments.append(line[2:-1])
            line=file.readline()
            
#read E0
        array=string.split(line)
        self.E0=float(array[1])

#read background bounds and order
#BACKGROUND lowx (order)  highx
        line=file.readline()
        array=string.split(line)
        rawlowx = float(array[1])
        rawhighx = float(array[3])
        raworder = int(array[2][1:-1])
        
#read spline info into makers and orders lists
#SPLINE marker (order) marker (order) marker .....
        line=file.readline() 
        array=string.split(line)
        markers=[]
        orders=[]
        
        for i in range(1,len(array)-2,2):
            markers.append(float(array[i]))
            orders.append(int(array[i+1][1]))
        markers.append(float(array[-2])) 
        
#check to see if k-window is specified
#if not, column header is stripped
        line=file.readline()
        array=string.split(line)
        if(array[0]=='KWIN'):
            window=(float(array[1]),float(array[2]))
            line=file.readline()
       
        
#file stream is now data, read it
        arrs=self.readArray(file)
        file.close()

        #arrs looks like:
        #[ [col1 col2 col3 col4]
        #  [col1 col2 col3 col4]
        #  ....
        #  ]]
        #transpose to get columns in useful format
        
        data=transpose(arrs)
        xdata=data[0].tolist()
        i0data=data[2].tolist()
        ydata=data[3].tolist()
    
        self.resetPlots()
        
        rawlowx=calc.getClosest(rawlowx,xdata)
        rawhighx=calc.getClosest(rawhighx,xdata)
        
        self.setupRawPlot(xdata,ydata,rawlowx,rawhighx,raworder)
        self.setupNormPlot(xdata,markers,orders)
        self.i0.setI0Data(xdata,i0data)
        
        kmax=calc.toKSpace(xdata[-1],self.E0)
        self.setupXAFSPlot(kmax,window[0],window[1])
        
        self.raw.updatePlot()