Ejemplo n.º 1
0
    def preProcess(self, _edObject=None):
        EDPluginControl.preProcess(self)
        EDVerbose.DEBUG("EDPluginBioSaxsReprocessv1_0.preProcess")
        # Load the execution plugin
        self.__edPluginExecTemplate = self.loadPlugin(
            self.__strControlledPluginName)

        self.strDetector = self.xsdInputData.getDetector().value
        self.strOperation = self.xsdInputData.getOperation().value
        self.strDirectory = self.xsdInputData.getDirectory().value
        self.beamCenterX = self.xsdInputData.getBeamCenterX().value
        self.pixelSizeX = self.xsdInputData.getPixelSizeX().value
        self.beamCenterY = self.xsdInputData.getBeamCenterY().value
        self.pixelSizeY = self.xsdInputData.getPixelSizeY().value

        self.beamStopDiode = self.xsdInputData.beamStopDiode.value
        self.code = self.xsdInputData.getCode().value
        self.comments = self.xsdInputData.getComments().value
        self.concentration = self.xsdInputData.getConcentration().value
        self.keepOriginal = bool(self.xsdInputData.getKeepOriginal().value)
        self.machineCurrent = self.xsdInputData.machineCurrent.value
        self.wavelength = self.xsdInputData.wavelength.value
        self.strPrefix = self.xsDataInputSPD.getPrefix.value

        self.normalisation = self.xsdInputData.getNomalisation().value
        self.maskFile = self.xsdInputData.maskFile.getPath().value

        if self.xsdInputData.getRunNumber() is not None:
            self.runNumber = self.xsdInputData.getRunNumber().value

        if self.xsdInputData.getSpecVersion() is not None:
            self.specVersion = self.xsdInputData.getSpecVersion().value
        if self.xsdInputData.getSpecVariableAbort() is not None:
            self.specAbort = self.xsdInputData.getSpecVariableAbort().value
        if self.xsdInputData.getSpecVariableStatus() is not None:
            self.specStatus = self.xsdInputData.getSpecVariableStatus().value
        if self.specVersion and self.specAbort and self.specStatus:
            EDUtilsBioSaxs.initSpec(self.specVersion, self.specStatus,
                                    self.specAbort)

        if not os.path.isfile(self.maskFile):
            self.showMessage(4,
                             "Mask file '%s' not found!" % self.strDirectory)
            self.setFailure()

#        if self.strOperation not in ("-2", "-1", "0", "1", "2", "3"):
        if self.strOperation not in [
                "normalisation", "reprocess", "average", "complete"
        ]:
            self.showMessage(4, "Invalid operation '%s'!" % self.strOperation)
            self.setFailure()

        self.firstFrame = self.xsdInputData.getFirstFrame().value
        self.lastFrame = self.xsdInputData.getLastFrame().value
Ejemplo n.º 2
0
    def preProcess(self, _edObject=None):
        EDPluginControl.preProcess(self)
        EDVerbose.DEBUG("EDPluginBioSaxsReprocessv1_0.preProcess")
        # Load the execution plugin
        self.__edPluginExecTemplate = self.loadPlugin(self.__strControlledPluginName)

        self.strDetector = self.xsdInputData.getDetector().value
        self.strOperation = self.xsdInputData.getOperation().value
        self.strDirectory = self.xsdInputData.getDirectory().value
        self.beamCenterX = self.xsdInputData.getBeamCenterX().value
        self.pixelSizeX = self.xsdInputData.getPixelSizeX().value
        self.beamCenterY = self.xsdInputData.getBeamCenterY().value
        self.pixelSizeY = self.xsdInputData.getPixelSizeY().value


        self.beamStopDiode = self.xsdInputData.beamStopDiode.value
        self.code = self.xsdInputData.getCode().value
        self.comments = self.xsdInputData.getComments().value
        self.concentration = self.xsdInputData.getConcentration().value
        self.keepOriginal = bool(self.xsdInputData.getKeepOriginal().value)
        self.machineCurrent = self.xsdInputData.machineCurrent.value
        self.wavelength = self.xsdInputData.wavelength.value
        self.strPrefix = self.xsDataInputSPD.getPrefix.value

        self.normalisation = self.xsdInputData.getNomalisation().value
        self.maskFile = self.xsdInputData.maskFile.getPath().value

        if self.xsdInputData.getRunNumber() is not None:
            self.runNumber = self.xsdInputData.getRunNumber().value

        if self.xsdInputData.getSpecVersion() is not None:
            self.specVersion = self.xsdInputData.getSpecVersion().value
        if self.xsdInputData.getSpecVariableAbort() is not None:
            self.specAbort = self.xsdInputData.getSpecVariableAbort().value
        if self.xsdInputData.getSpecVariableStatus() is not None:
            self.specStatus = self.xsdInputData.getSpecVariableStatus().value
        if self.specVersion and  self.specAbort and  self.specStatus:
            EDUtilsBioSaxs.initSpec(self.specVersion, self.specStatus, self.specAbort)

        if not os.path.isfile(self.maskFile):
            self.showMessage(4, "Mask file '%s' not found!" % self.strDirectory)
            self.setFailure()

#        if self.strOperation not in ("-2", "-1", "0", "1", "2", "3"):
        if self.strOperation not in ["normalisation", "reprocess", "average", "complete"]:
            self.showMessage(4, "Invalid operation '%s'!" % self.strOperation)
            self.setFailure()

        self.firstFrame = self.xsdInputData.getFirstFrame().value
        self.lastFrame = self.xsdInputData.getLastFrame().value
Ejemplo n.º 3
0
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        EDVerbose.DEBUG("EDPluginBioSaxsReprocessv1_0.process")

        if not os.path.isdir(self.strDirectory):
            self.showMessage(4,
                             "Directory '%s' not found!" % self.strDirectory)
            self.setFailure()

        self.strRawDir = os.path.join(self.strDirectory, "raw")
        if not os.path.isdir(self.strRawDir):
            self.showMessage(4,
                             "Directory  Raw '%s' not found!" % self.strRawDir)
            self.setFailure()

        self.str1dDir = os.path.join(self.strDirectory, "1d")
        if not os.path.isdir(self.str1dDir):
            try:
                os.mkdir(self.str1dDir)
            except:
                self.showMessage(
                    4, "Could not create directory '1d' in '%s'!" %
                    self.strDirectory)
                self.setFailure()

        self.str2dDir = os.path.join(self.strDirectory, "2d")
        if not os.path.exists(self.str2dDir):
            try:
                os.mkdir(self.str2dDir)
            except Exception:
                self.showMessage(
                    4, "Could not create directory '2d' in '%s'!" %
                    self.strDirectory)
                self.setFailure()

        self.strMiscDir = os.path.join(self.strDirectory, "misc")
        if not os.path.exists(self.strMiscDir):
            try:
                os.mkdir(self.strMiscDir)
            except Exception:
                self.showMessage(
                    4, "Could not create directory 'misc' in '%s'!" %
                    self.strDirectory)
                self.setFailure()

#        runNumberList = []
        iFirstFrame = int(self.firstFrame)
        iLastFrame = int(self.lastFrame)
        if self.runNumber is None:
            for filename in os.listdir(self.strRawDir):
                fullPathFilename = os.path.join(self.strRawDir, filename)
                if os.path.isfile(fullPathFilename):
                    prefix, run, frame, extra, extension = EDUtilsBioSaxs.getFilenameDetails(
                        filename)
                    try:
                        iFrame = int(frame)
                    except ValueError:
                        iFrame = -1
                    if (prefix == self.strPrefix) and (run != "") and\
                            (iFrame >= iFirstFrame) and (iFrame <= iLastFrame) and \
                            ((self.strDetector == "pilatus" and extension == "edf") or \
                            (self.strDetector == "vantec" and extension == "gfrm")):
                        if run not in self.dictRunFrame:
                            self.dictRunFrame[run] = [frame]
                        else:
                            self.dictRunFrame[run].append(frame)
        else:

            if self.bIsOnline:  #just treat the last frame of the runs
                for run in self.runNumber.split(","):
                    self.dictRunFrame[run] = ["%02d" % int(self.FrameLast)]
            else:
                listInRunNr = [int(i) for i in self.runNumber.split(",")]
                for filename in os.listdir(self.strRawDir):
                    fullPathFilename = os.path.join(self.strRawDir, filename)
                    if os.path.isfile(fullPathFilename):
                        prefix, run, frame, extra, extension = EDUtilsBioSaxs.getFilenameDetails(
                            filename)
                        try:
                            iRun = int(run)
                        except ValueError:
                            iRun = -1
                        try:
                            iFrame = int(frame)
                        except ValueError:
                            iFrame = -1
                        if (prefix == self.strPrefix) and (iRun in listInRunNr) and \
                                (iFrame >= iFirstFrame) and (iFrame <= iLastFrame)  and \
                                ((self.strDetector == "pilatus" and extension == "edf") or \
                                (self.strDetector == "vantec" and extension == "gfrm")):
                            if run not in self.dictRunFrame:
                                self.dictRunFrame[run] = [frame]
                            else:
                                self.dictRunFrame[run].append(frame)

        if len(self.dictRunFrame) == 0:
            self.showMessage(
                4, "There are no runs for prefix '%s'!" % self.strPrefix)
            self.setFailure()
        else:
            runNumberList = self.dictRunFrame.keys()
            runNumberList.sort()

#
#        hdfDictionary = HDFDictionary.HDFDictionary()
#
#        dictionaryEDF = "EDF_" + self.strDetector.upper()
#
#        status, dictionary = hdfDictionary.get(os.path.join(sys.path[0], "Reprocess.xml"), dictionaryEDF)
#        if status != 0:
#            self.showMessage(3, "Could not get '%s' dictionary!" % dictionaryEDF)
#
#        #print dictionary

        if not self.keepOriginal:
            directory1D_REP = ""
            directory2D_REP = ""
            directoryMISC_REP = ""
        else:
            i = 0
            while True:
                directory1D_REP = os.path.join(self.str1dDir,
                                               "reprocess%i" % i)
                if os.path.isdir(directory1D_REP):
                    i += 1
                else:
                    try:
                        os.mkdir(directory1D_REP)
                    except Exception:
                        self.showMessage(
                            3, "Could not create reprocess directory '%s'!" %
                            directory1D_REP)
                    break

            i = 0
            while True:
                directory2D_REP = os.path.join(self.str2dDir,
                                               "reprocess%i" % i)
                if os.path.exists(directory2D_REP):
                    i += 1
                else:
                    try:
                        os.mkdir(directory2D_REP)
                    except Exception:
                        self.showMessage(
                            3, "Could not create reprocess directory '%s'!" %
                            directory2D_REP)
                    break

            i = 0
            while True:
                directoryMISC_REP = os.path.join(self.strMiscDir,
                                                 "reprocess%i" % i)
                if os.path.exists(directoryMISC_REP):
                    i += 1
                else:
                    try:
                        os.mkdir(directoryMISC_REP)
                    except Exception:
                        self.showMessage(
                            3, "Could not create reprocess directory '%s'!" %
                            directoryMISC_REP)
                    break

        for runNumber in runNumberList:
            doOneRunNumber(runNumber)
        self.showMessage(0, "The data reprocessing is done!")

        self.__edPluginExecTemplate.connectSUCCESS(self.doSuccessExecTemplate)
        self.__edPluginExecTemplate.connectFAILURE(self.doFailureExecTemplate)
        self.__edPluginExecTemplate.executeSynchronous()
Ejemplo n.º 4
0
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        EDVerbose.DEBUG("EDPluginBioSaxsReprocessv1_0.process")

        if not os.path.isdir(self.strDirectory):
            self.showMessage(4, "Directory '%s' not found!" % self.strDirectory)
            self.setFailure()

        self.strRawDir = os.path.join(self.strDirectory, "raw")
        if not os.path.isdir(self.strRawDir):
            self.showMessage(4, "Directory  Raw '%s' not found!" % self.strRawDir)
            self.setFailure()

        self.str1dDir = os.path.join(self.strDirectory, "1d")
        if not os.path.isdir(self.str1dDir):
            try:
                os.mkdir(self.str1dDir)
            except :
                self.showMessage(4, "Could not create directory '1d' in '%s'!" % self.strDirectory)
                self.setFailure()

        self.str2dDir = os.path.join(self.strDirectory, "2d")
        if not os.path.exists(self.str2dDir):
            try:
                os.mkdir(self.str2dDir)
            except Exception:
                self.showMessage(4, "Could not create directory '2d' in '%s'!" % self.strDirectory)
                self.setFailure()

        self.strMiscDir = os.path.join(self.strDirectory, "misc")
        if not os.path.exists(self.strMiscDir):
            try:
                os.mkdir(self.strMiscDir)
            except Exception:
                self.showMessage(4, "Could not create directory 'misc' in '%s'!" % self.strDirectory)
                self.setFailure()



#        runNumberList = []
        iFirstFrame = int(self.firstFrame)
        iLastFrame = int(self.lastFrame)
        if self.runNumber is None:
            for filename in os.listdir(self.strRawDir):
                fullPathFilename = os.path.join(self.strRawDir, filename)
                if os.path.isfile(fullPathFilename):
                    prefix, run, frame, extra, extension = EDUtilsBioSaxs.getFilenameDetails(filename)
                    try:
                        iFrame = int(frame)
                    except ValueError:
                        iFrame = -1
                    if (prefix == self.strPrefix) and (run != "") and\
                            (iFrame >= iFirstFrame) and (iFrame <= iLastFrame) and \
                            ((self.strDetector == "pilatus" and extension == "edf") or \
                            (self.strDetector == "vantec" and extension == "gfrm")):
                        if run not in self.dictRunFrame:
                            self.dictRunFrame[run] = [frame]
                        else:
                            self.dictRunFrame[run].append(frame)
        else:


            if self.bIsOnline: #just treat the last frame of the runs
                for run in self.runNumber.split(","):
                    self.dictRunFrame[run] = ["%02d" % int(self.FrameLast)]
            else:
                listInRunNr = [int(i) for i in self.runNumber.split(",")]
                for filename in os.listdir(self.strRawDir):
                    fullPathFilename = os.path.join(self.strRawDir, filename)
                    if os.path.isfile(fullPathFilename):
                        prefix, run, frame, extra, extension = EDUtilsBioSaxs.getFilenameDetails(filename)
                        try:
                            iRun = int(run)
                        except ValueError:
                            iRun = -1
                        try:
                            iFrame = int(frame)
                        except ValueError:
                            iFrame = -1
                        if (prefix == self.strPrefix) and (iRun in listInRunNr) and \
                                (iFrame >= iFirstFrame) and (iFrame <= iLastFrame)  and \
                                ((self.strDetector == "pilatus" and extension == "edf") or \
                                (self.strDetector == "vantec" and extension == "gfrm")):
                            if run not in self.dictRunFrame:
                                self.dictRunFrame[run] = [frame]
                            else:
                                self.dictRunFrame[run].append(frame)

        if len(self.dictRunFrame) == 0:
            self.showMessage(4, "There are no runs for prefix '%s'!" % self.strPrefix)
            self.setFailure()
        else:
            runNumberList = self.dictRunFrame.keys()
            runNumberList.sort()

#
#        hdfDictionary = HDFDictionary.HDFDictionary()
#
#        dictionaryEDF = "EDF_" + self.strDetector.upper()
#
#        status, dictionary = hdfDictionary.get(os.path.join(sys.path[0], "Reprocess.xml"), dictionaryEDF)
#        if status != 0:
#            self.showMessage(3, "Could not get '%s' dictionary!" % dictionaryEDF)
#
#        #print dictionary

        if not self.keepOriginal:
            directory1D_REP = ""
            directory2D_REP = ""
            directoryMISC_REP = ""
        else:
            i = 0
            while True:
                directory1D_REP = os.path.join(self.str1dDir, "reprocess%i" % i)
                if os.path.isdir(directory1D_REP):
                    i += 1
                else:
                    try:
                        os.mkdir(directory1D_REP)
                    except Exception:
                        self.showMessage(3, "Could not create reprocess directory '%s'!" % directory1D_REP)
                    break

            i = 0
            while True:
                directory2D_REP = os.path.join(self.str2dDir, "reprocess%i" % i)
                if os.path.exists(directory2D_REP):
                    i += 1
                else:
                    try:
                        os.mkdir(directory2D_REP)
                    except Exception:
                        self.showMessage(3, "Could not create reprocess directory '%s'!" % directory2D_REP)
                    break

            i = 0
            while True:
                directoryMISC_REP = os.path.join(self.strMiscDir, "reprocess%i" % i)
                if os.path.exists(directoryMISC_REP):
                    i += 1
                else:
                    try:
                        os.mkdir(directoryMISC_REP)
                    except Exception:
                        self.showMessage(3, "Could not create reprocess directory '%s'!" % directoryMISC_REP)
                    break

        for runNumber in runNumberList:
            doOneRunNumber(runNumber)
        self.showMessage(0, "The data reprocessing is done!")






        self.__edPluginExecTemplate.connectSUCCESS(self.doSuccessExecTemplate)
        self.__edPluginExecTemplate.connectFAILURE(self.doFailureExecTemplate)
        self.__edPluginExecTemplate.executeSynchronous()