def calc_DIFF_images(*args):
    if len(args) == 4:
        noSlice1, myImgStack1, myShape1, xValues1 = xpeemreg.loadHDF5(args[0])
        noSlice2, myImgStack2, myShape2, xValues2 = xpeemreg.loadHDF5(args[1])
        noSlice = noSlice1 + noSlice2
        myImgStack = np.concatenate((myImgStack1, myImgStack2), axis=0)
        myShape = np.shape(myImgStack)
        refImg = myImgStack[0]
        regImg, shiftX, shiftY = xpeemreg.reduce_DRIFT(noSlice, myImgStack, myShape, refImg, args[2], args[3])
    elif len(args) == 5:
        noSlice1, myImgStack1, myShape1, xValues1 = xpeemreg.loadHDF5(args[0])
        noSlice2, myImgStack2, myShape2, xValues2 = xpeemreg.loadHDF5(args[1])
        noSlice = noSlice1 + noSlice2
        myImgStack = np.concatenate((myImgStack1, myImgStack2), axis=0)
        myShape = np.shape(myImgStack)
        refImg = myImgStack[0]
        noSliceNorm, imgStackNorm, myShapeNorm, xValuesNorm = xpeemreg.loadHDF5(args[2])
        imgNorm = np.sum(imgStackNorm, axis=0, dtype="float32") / len(imgStackNorm)
        imgNormStack = [myImgStack[theSlice].astype("float32") / imgNorm for theSlice in range(noSlice)]
        imgNormStack = np.array(imgNormStack)
        regImg, shiftX, shiftY = xpeemreg.reduce_DRIFT(noSlice, imgNormStack, myShape, refImg, args[3], args[4])
    regImg1 = regImg[: noSlice / 2]
    regImg2 = regImg[noSlice / 2 :]
    regImgSum1 = np.sum(regImg1, axis=0, dtype="float32") / (noSlice / 2)
    regImgSum2 = np.sum(regImg2, axis=0, dtype="float32") / (noSlice / 2)
    diffImgArray = (regImgSum1 - regImgSum2) / (regImgSum1 + regImgSum2)
    return myImgStack[: noSlice / 2], myImgStack[noSlice / 2 :], regImgSum1, regImgSum2, diffImgArray, shiftX, shiftY
 def load4files(self):
     self.loadContext = 'FOUR FILES'
     self.fileName1 = str(QtGui.QFileDialog.getOpenFileName(self,'Pick a DATA file',self.dataDirectory, 'NeXuS (*.nxs)'))
     self.noSlice1,self.imgStack1,self.myShape1,self.xValues1 = xpeem.loadHDF5(self.fileName1)
     if self.xValues1 == None:
         self.imageView.setImage(self.imgStack1)
     else:
         self.imageView.setImage(self.imgStack1,xvals=self.xValues1)
     self.changeLabelText(self.fileName1)
     self.fileName2 = str(QtGui.QFileDialog.getOpenFileName(self,'Pick a DATA file',self.dataDirectory, 'NeXuS (*.nxs)'))
     self.noSlice2,self.imgStack2,self.myShape2,self.xValues2 = xpeem.loadHDF5(self.fileName2)
     if self.xValues2 == None:
         self.imageView.setImage(self.imgStack2)
     else:
         self.imageView.setImage(self.imgStack2,xvals=self.xValues2)
     self.changeLabelText(self.fileName2)
     self.fileName3 = str(QtGui.QFileDialog.getOpenFileName(self,'Pick a DATA file',self.dataDirectory, 'NeXuS (*.nxs)'))
     self.noSlice3,self.imgStack3,self.myShape3,self.xValues3 = xpeem.loadHDF5(self.fileName3)
     if self.xValues3 == None:
         self.imageView.setImage(self.imgStack3)
     else:
         self.imageView.setImage(self.imgStack3,xvals=self.xValues3)
     self.changeLabelText(self.fileName3)
     self.fileName4 = str(QtGui.QFileDialog.getOpenFileName(self,'Pick a DATA file',self.dataDirectory, 'NeXuS (*.nxs)'))
     self.noSlice4,self.imgStack4,self.myShape4,self.xValues4 = xpeem.loadHDF5(self.fileName4)
     if self.xValues4 == None:
         self.imageView.setImage(self.imgStack4)
     else:
         self.imageView.setImage(self.imgStack4,xvals=self.xValues4)
     self.changeLabelText(self.fileName4)
def calc_DIFF_spectra(*args):
    if len(args) == 4:
        noSlice1,myImgStack1,myShape1,xValues1 = xpeemreg.loadHDF5(args[0])
        noSlice2,myImgStack2,myShape2,xValues2 = xpeemreg.loadHDF5(args[1])
        noSlice = noSlice1+noSlice2
        myImgStack = np.concatenate((myImgStack1,myImgStack2),axis=0)
        myShape = np.shape(myImgStack)
        refImg = myImgStack[0]
        regImg,shiftX,shiftY = xpeemreg.reduce_DRIFT(noSlice,myImgStack,myShape,refImg,args[2],args[3])
    elif len(args) == 5:
        noSlice1,myImgStack1,myShape1,xValues1 = xpeemreg.loadHDF5(args[0])
        noSlice2,myImgStack2,myShape2,xValues2 = xpeemreg.loadHDF5(args[1])
        noSlice = noSlice1+noSlice2
        myImgStack = np.concatenate((myImgStack1,myImgStack2),axis=0)
        myShape = np.shape(myImgStack)
        refImg = myImgStack[0]
        noSliceNorm,imgStackNorm,myShapeNorm,xValuesNorm = xpeemreg.loadHDF5(args[2])
        imgNorm = np.sum(imgStackNorm,axis=0,dtype='float32')/len(imgStackNorm)
        imgNormStack = [myImgStack[theSlice].astype('float32')/imgNorm for theSlice in range(noSlice)]
        imgNormStack = np.array(imgNormStack)
        regImg,shiftX,shiftY = xpeemreg.reduce_DRIFT(noSlice,imgNormStack,myShape,refImg,args[3],args[4])

    regImg1 = regImg[:noSlice/2]
    regImg2 = regImg[noSlice/2:]
    diffStack = [(regImg1[theSlice].astype('float32')-regImg2[theSlice].astype('float32'))/(regImg1[theSlice].astype('float32')+regImg2[theSlice].astype('float32')) for theSlice in range(noSlice/2)]
    return myImgStack[:noSlice/2],myImgStack[noSlice/2:],regImg1,regImg2,diffStack,shiftX,shiftY
def calc_ABS_NORM_DIFF_images(*args):
    if len(args) == 6:
        noSlice1,myImgStack1,myShape1,xValues1 = xpeemreg.loadHDF5(args[0])
        noSlice2,myImgStack2,myShape2,xValues2 = xpeemreg.loadHDF5(args[1])
        noSlice3,myImgStack3,myShape3,xValues3 = xpeemreg.loadHDF5(args[2])
        noSlice4,myImgStack4,myShape4,xValues4 = xpeemreg.loadHDF5(args[3])
        noSlice = noSlice1+noSlice2+noSlice3+noSlice4
        myImgStack = np.concatenate((myImgStack1,myImgStack2,myImgStack3,myImgStack4),axis=0)
        myShape = np.shape(myImgStack)
        refImg = myImgStack[0]
        regImg,shiftX,shiftY = xpeemreg.reduce_DRIFT(noSlice,myImgStack,myShape,refImg,args[4],args[5])
    elif len(args) == 7:
        noSlice1,myImgStack1,myShape1,xValues1 = xpeemreg.loadHDF5(args[0])
        noSlice2,myImgStack2,myShape2,xValues2 = xpeemreg.loadHDF5(args[1])
        noSlice3,myImgStack3,myShape3,xValues3 = xpeemreg.loadHDF5(args[2])
        noSlice4,myImgStack4,myShape4,xValues4 = xpeemreg.loadHDF5(args[3])
        noSlice = noSlice1+noSlice2+noSlice3+noSlice4
        myImgStack = np.concatenate((myImgStack1,myImgStack2,myImgStack3,myImgStack4),axis=0)
        myShape = np.shape(myImgStack)
        refImg = myImgStack[0]
        noSliceNorm,imgStackNorm,myShapeNorm,xValuesNorm = xpeemreg.loadHDF5(args[4])
        imgNorm = np.sum(imgStackNorm,axis=0,dtype='float32')/len(imgStackNorm)
        imgNormStack = [myImgStack[theSlice].astype('float32')/imgNorm for theSlice in range(noSlice)]
        imgNormStack = np.array(imgNormStack)
        regImg,shiftX,shiftY = xpeemreg.reduce_DRIFT(noSlice,imgNormStack,myShape,refImg,args[5],args[6])
    regImg1 = regImg[:noSlice/4]
    regImg2 = regImg[noSlice/4:2*noSlice/4]
    regImg3 = regImg[2*noSlice/4:3*noSlice/4]
    regImg4 = regImg[3*noSlice/4:]
    regImgSum1 = np.sum(regImg1,axis=0,dtype='float32')/(noSlice/4)
    regImgSum2 = np.sum(regImg2,axis=0,dtype='float32')/(noSlice/4)
    regImgSum3 = np.sum(regImg3,axis=0,dtype='float32')/(noSlice/4)
    regImgSum4 = np.sum(regImg4,axis=0,dtype='float32')/(noSlice/4)
    diffImgArray = ((regImgSum2-regImgSum1)/(regImgSum2+regImgSum1)-(regImgSum4-regImgSum3)/(regImgSum4+regImgSum3))
    return myImgStack[:noSlice/4],myImgStack[noSlice/4:2*noSlice/4],myImgStack[2*noSlice/4:3*noSlice/4],myImgStack[3*noSlice/4:],regImgSum1,regImgSum2,regImgSum3,regImgSum4, diffImgArray,shiftX,shiftY
def calc_single_spectrum(*args):
    if len(args) == 3:
        noSlice,myImgStack,myShape,xValues = xpeemreg.loadHDF5(args[0])
        refImg = myImgStack[0]
        regImg,shiftX,shiftY = xpeemreg.reduce_DRIFT(noSlice,myImgStack,myShape,refImg,args[1],args[2])
    elif len(args) == 4:
        noSlice,myImgStack,myShape,xValues = xpeemreg.loadHDF5(args[0])
        refImg = myImgStack[0]
        noSliceNorm,imgStackNorm,myShapeNorm,xValuesNorm = xpeemreg.loadHDF5(args[1])
        imgNorm = np.sum(imgStackNorm,axis=0,dtype='float32')/len(imgStackNorm)
        imgNormStack = [myImgStack[theSlice].astype('float32')/imgNorm for theSlice in range(noSlice)]
        imgNormStack = np.array(imgNormStack)
        regImg,shiftX,shiftY = xpeemreg.reduce_DRIFT(noSlice,imgNormStack,myShape,refImg,args[2],args[3])
    return myImgStack,regImg,shiftX,shiftY
Exemple #6
0
def calc_ABS_NORM_DIFF_images(*args):
    if len(args) == 6:
        noSlice1, myImgStack1, myShape1, xValues1 = xpeemreg.loadHDF5(args[0])
        noSlice2, myImgStack2, myShape2, xValues2 = xpeemreg.loadHDF5(args[1])
        noSlice3, myImgStack3, myShape3, xValues3 = xpeemreg.loadHDF5(args[2])
        noSlice4, myImgStack4, myShape4, xValues4 = xpeemreg.loadHDF5(args[3])
        noSlice = noSlice1 + noSlice2 + noSlice3 + noSlice4
        myImgStack = np.concatenate(
            (myImgStack1, myImgStack2, myImgStack3, myImgStack4), axis=0)
        myShape = np.shape(myImgStack)
        refImg = myImgStack[0]
        regImg, shiftX, shiftY = xpeemreg.reduce_DRIFT(noSlice, myImgStack,
                                                       myShape, refImg,
                                                       args[4], args[5])
    elif len(args) == 7:
        noSlice1, myImgStack1, myShape1, xValues1 = xpeemreg.loadHDF5(args[0])
        noSlice2, myImgStack2, myShape2, xValues2 = xpeemreg.loadHDF5(args[1])
        noSlice3, myImgStack3, myShape3, xValues3 = xpeemreg.loadHDF5(args[2])
        noSlice4, myImgStack4, myShape4, xValues4 = xpeemreg.loadHDF5(args[3])
        noSlice = noSlice1 + noSlice2 + noSlice3 + noSlice4
        myImgStack = np.concatenate(
            (myImgStack1, myImgStack2, myImgStack3, myImgStack4), axis=0)
        myShape = np.shape(myImgStack)
        refImg = myImgStack[0]
        noSliceNorm, imgStackNorm, myShapeNorm, xValuesNorm = xpeemreg.loadHDF5(
            args[4])
        imgNorm = np.sum(imgStackNorm, axis=0,
                         dtype='float32') / len(imgStackNorm)
        imgNormStack = [
            myImgStack[theSlice].astype('float32') / imgNorm
            for theSlice in range(noSlice)
        ]
        imgNormStack = np.array(imgNormStack)
        regImg, shiftX, shiftY = xpeemreg.reduce_DRIFT(noSlice, imgNormStack,
                                                       myShape, refImg,
                                                       args[5], args[6])
    regImg1 = regImg[:noSlice / 4]
    regImg2 = regImg[noSlice / 4:2 * noSlice / 4]
    regImg3 = regImg[2 * noSlice / 4:3 * noSlice / 4]
    regImg4 = regImg[3 * noSlice / 4:]
    regImgSum1 = np.sum(regImg1, axis=0, dtype='float32') / (noSlice / 4)
    regImgSum2 = np.sum(regImg2, axis=0, dtype='float32') / (noSlice / 4)
    regImgSum3 = np.sum(regImg3, axis=0, dtype='float32') / (noSlice / 4)
    regImgSum4 = np.sum(regImg4, axis=0, dtype='float32') / (noSlice / 4)
    diffImgArray = ((regImgSum2 - regImgSum1) / (regImgSum2 + regImgSum1) -
                    (regImgSum4 - regImgSum3) / (regImgSum4 + regImgSum3))
    return myImgStack[:noSlice / 4], myImgStack[
        noSlice / 4:2 * noSlice /
        4], myImgStack[2 * noSlice / 4:3 * noSlice / 4], myImgStack[
            3 * noSlice /
            4:], regImgSum1, regImgSum2, regImgSum3, regImgSum4, diffImgArray, shiftX, shiftY
 def load4files(self):
     self.loadContext = 'FOUR FILES'
     self.fileName1 = str(
         QtGui.QFileDialog.getOpenFileName(self, 'Pick a DATA file',
                                           self.dataDirectory,
                                           'NeXuS (*.nxs)'))
     self.noSlice1, self.imgStack1, self.myShape1, self.xValues1 = xpeem.loadHDF5(
         self.fileName1)
     if self.xValues1 == None:
         self.imageView.setImage(self.imgStack1)
     else:
         self.imageView.setImage(self.imgStack1, xvals=self.xValues1)
     self.changeLabelText(self.fileName1)
     self.fileName2 = str(
         QtGui.QFileDialog.getOpenFileName(self, 'Pick a DATA file',
                                           self.dataDirectory,
                                           'NeXuS (*.nxs)'))
     self.noSlice2, self.imgStack2, self.myShape2, self.xValues2 = xpeem.loadHDF5(
         self.fileName2)
     if self.xValues2 == None:
         self.imageView.setImage(self.imgStack2)
     else:
         self.imageView.setImage(self.imgStack2, xvals=self.xValues2)
     self.changeLabelText(self.fileName2)
     self.fileName3 = str(
         QtGui.QFileDialog.getOpenFileName(self, 'Pick a DATA file',
                                           self.dataDirectory,
                                           'NeXuS (*.nxs)'))
     self.noSlice3, self.imgStack3, self.myShape3, self.xValues3 = xpeem.loadHDF5(
         self.fileName3)
     if self.xValues3 == None:
         self.imageView.setImage(self.imgStack3)
     else:
         self.imageView.setImage(self.imgStack3, xvals=self.xValues3)
     self.changeLabelText(self.fileName3)
     self.fileName4 = str(
         QtGui.QFileDialog.getOpenFileName(self, 'Pick a DATA file',
                                           self.dataDirectory,
                                           'NeXuS (*.nxs)'))
     self.noSlice4, self.imgStack4, self.myShape4, self.xValues4 = xpeem.loadHDF5(
         self.fileName4)
     if self.xValues4 == None:
         self.imageView.setImage(self.imgStack4)
     else:
         self.imageView.setImage(self.imgStack4, xvals=self.xValues4)
     self.changeLabelText(self.fileName4)
 def load1file(self):
     self.loadContext = 'ONE FILE'
     self.fileName = str(QtGui.QFileDialog.getOpenFileName(self,'Pick a DATA file',self.dataDirectory, 'NeXuS HDF5 (*.nxs *.hdf5)'))
     self.noSlice,self.imgStack,self.myShape,self.xValues = xpeem.loadHDF5(self.fileName)
     if self.xValues == None:
         self.imageView.setImage(self.imgStack)
     else:
         self.imageView.setImage(self.imgStack,xvals=self.xValues)
     self.changeLabelText(self.fileName)
 def loadNormFile(self):
     self.fileNameNorm = str(
         QtGui.QFileDialog.getOpenFileName(self,
                                           'Pick a NORMALIZATION file',
                                           self.dataDirectory,
                                           'NeXuS (*.nxs)'))
     self.noSliceNorm, self.imgStackNorm, self.myShapeNorm, self.xValuesNorm = xpeem.loadHDF5(
         self.fileNameNorm)
     self.imgNorm = np.sum(self.imgStackNorm, axis=0,
                           dtype='float32') / len(self.imgStackNorm)
 def load1file(self):
     self.loadContext = 'ONE FILE'
     self.fileName = str(
         QtGui.QFileDialog.getOpenFileName(self, 'Pick a DATA file',
                                           self.dataDirectory,
                                           'NeXuS HDF5 (*.nxs *.hdf5)'))
     self.noSlice, self.imgStack, self.myShape, self.xValues = xpeem.loadHDF5(
         self.fileName)
     if self.xValues == None:
         self.imageView.setImage(self.imgStack)
     else:
         self.imageView.setImage(self.imgStack, xvals=self.xValues)
     self.changeLabelText(self.fileName)
 def loadNormFile(self):
     self.fileNameNorm = str(QtGui.QFileDialog.getOpenFileName(self,'Pick a NORMALIZATION file',self.dataDirectory, 'NeXuS (*.nxs)'))
     self.noSliceNorm,self.imgStackNorm,self.myShapeNorm,self.xValuesNorm = xpeem.loadHDF5(self.fileNameNorm)
     self.imgNorm = np.sum(self.imgStackNorm,axis=0,dtype='float32')/len(self.imgStackNorm)