示例#1
0
    def postProcess(self, _edObject=None):
        """
        postProcess of the plugin EDPluginSPDCakev1_5.py:
        - convert to HDF if needed (to be implemented)
        - convert to chiplot or xye or cif if needed
        - move images (if needed) or delete .cor image 
        - set result XML   
        """
        EDPluginSPDCorrectv10.postProcess(self)
        self.DEBUG("EDPluginSPDCakev1_5.postProcess")

        if not os.path.isdir(self.dictGeometry["OutputDirCake"]):
            os.makedirs(self.dictGeometry["OutputDirCake"])

        strInputImagePathNoSfx = os.path.splitext(
            os.path.basename(self.pathToInputFile))[0]
        strSpdoutCake = strInputImagePathNoSfx + self.dictGeometry[
            "OutputFileType"]

        strOutputCakeFilePath = os.path.join(
            self.dictGeometry["OutputDirCake"], strSpdoutCake)
        xsDataResultSPD = XSDataResultSPDCake()

        if not self.getFireAndForget():
            strTempFilePath = None
            if "corrected" in self.dictRes:
                strSpdoutCor = self.dictRes["corrected"]
            if "regrouped" in self.dictRes:
                strTempFilePath = self.dictRes["regrouped"]

            if self.dictGeometry["OutputFileType"].lower() in [
                    ".hdf5", ".nexus", ".h5", ".nx"
            ]:
                self.WARNING(
                    "HDF5/Nexus output is not yet implemented in the SPD plugin."
                )

            if strTempFilePath is None:
                self.WARNING(
                    "Cannot copy output to %s as there is not input: %s " %
                    (strOutputCakeFilePath, self.dictRes))
            elif os.path.exists(strOutputCakeFilePath):
                self.WARNING(
                    "Destination file exists, I will leave result file in %s."
                    % strTempFilePath)
                strOutputCakeFilePath = strTempFilePath
            else:
                shutil.move(strTempFilePath, strOutputCakeFilePath)

            strOutputCorFilePath = os.path.join(self.dictGeometry["OutputDir"],
                                                os.path.split(strSpdoutCor)[1])
            if self.bDeleteCorImg:
                if os.path.isfile(strSpdoutCor):
                    os.remove(strSpdoutCor)
                else:
                    self.WARNING("Corrected file vanished before removal %s" %
                                 strSpdoutCor)
            else:
                strTempFilePathCor = os.path.join(self.getWorkingDirectory(),
                                                  strSpdoutCor)
                if self.dictGeometry["OutputFileType"].lower() in [
                        ".hdf5", ".nexus", ".h5", ".nx"
                ]:
                    self.WARNING(
                        "HDF5/Nexus output is not yet implemented in the SPD plugin."
                    )
                elif self.dictGeometry["OutputFileType"].lower() not in [
                        ".edf", ".azim", ".cor"
                ]:
                    self.WARNING(
                        "Output file format %s is not yet implemented in the SPD plugin."
                        % self.dictGeometry["OutputFileType"])

                if os.path.exists(strOutputCorFilePath):
                    self.WARNING(
                        "Destination file exists, I will leave result file in %s."
                        % strTempFilePathCor)
                    strOutputCorFilePath = os.path.abspath(strTempFilePathCor)
                else:

                    shutil.move(strTempFilePath, strOutputCorFilePath)
                xsDataFileCorr = XSDataFile()
                xsDataFileCorr.setPath(XSDataString(strOutputCorFilePath))
                xsDataResultSPD.setcorrectedFile(xsDataFileCorr)
#        # Create the output data
        xsDataFileCake = XSDataFile()
        xsDataFileCake.setPath(XSDataString(strOutputCakeFilePath))
        xsDataResultSPD.setCakedFile(xsDataFileCake)

        self.setDataOutput(xsDataResultSPD)
示例#2
0
    def postProcess(self, _edObject=None):
        """
        postProcess of the plugin EDPluginSPDCakev1_5.py:
        - convert to HDF if needed (to be implemented)
        - convert to chiplot or xye or cif if needed
        - move images (if needed) or delete .cor image 
        - set result XML   
        """
        EDPluginSPDCorrectv10.postProcess(self)
        self.DEBUG("EDPluginSPDCakev1_5.postProcess")

        if not os.path.isdir(self.dictGeometry["OutputDirCake"]):
            os.makedirs(self.dictGeometry["OutputDirCake"])



        strInputImagePathNoSfx = os.path.splitext(os.path.basename(self.pathToInputFile))[0]
        strSpdoutCake = strInputImagePathNoSfx + self.dictGeometry["OutputFileType"]

        strOutputCakeFilePath = os.path.join(self.dictGeometry["OutputDirCake"], strSpdoutCake)
        xsDataResultSPD = XSDataResultSPDCake()


        if not self.getFireAndForget():
            strTempFilePath = None
            if "corrected" in self.dictRes:
                strSpdoutCor = self.dictRes["corrected"]
            if "regrouped" in self.dictRes:
                strTempFilePath = self.dictRes["regrouped"]

            if self.dictGeometry["OutputFileType"].lower() in [".hdf5", ".nexus", ".h5", ".nx"]:
                self.WARNING("HDF5/Nexus output is not yet implemented in the SPD plugin.")

            if strTempFilePath is None:
                self.WARNING("Cannot copy output to %s as there is not input: %s " % (strOutputCakeFilePath, self.dictRes))
            elif os.path.exists(strOutputCakeFilePath):
                self.WARNING("Destination file exists, I will leave result file in %s." % strTempFilePath)
                strOutputCakeFilePath = strTempFilePath
            else:
                shutil.move(strTempFilePath, strOutputCakeFilePath)

            strOutputCorFilePath = os.path.join(self.dictGeometry["OutputDir"], os.path.split(strSpdoutCor)[1])
            if self.bDeleteCorImg:
                if os.path.isfile(strSpdoutCor):
                    os.remove(strSpdoutCor)
                else:
                    self.WARNING("Corrected file vanished before removal %s" % strSpdoutCor)
            else:
                strTempFilePathCor = os.path.join(self.getWorkingDirectory(), strSpdoutCor)
                if self.dictGeometry["OutputFileType"].lower() in [".hdf5", ".nexus", ".h5", ".nx"]:
                    self.WARNING("HDF5/Nexus output is not yet implemented in the SPD plugin.")
                elif self.dictGeometry["OutputFileType"].lower() not in [".edf", ".azim", ".cor"] :
                    self.WARNING("Output file format %s is not yet implemented in the SPD plugin." % self.dictGeometry["OutputFileType"])

                if os.path.exists(strOutputCorFilePath):
                    self.WARNING("Destination file exists, I will leave result file in %s." % strTempFilePathCor)
                    strOutputCorFilePath = os.path.abspath(strTempFilePathCor)
                else:

                    shutil.move(strTempFilePath, strOutputCorFilePath)
                xsDataFileCorr = XSDataFile()
                xsDataFileCorr.setPath(XSDataString(strOutputCorFilePath))
                xsDataResultSPD.setcorrectedFile(xsDataFileCorr)
#        # Create the output data
        xsDataFileCake = XSDataFile()
        xsDataFileCake.setPath(XSDataString(strOutputCakeFilePath))
        xsDataResultSPD.setCakedFile(xsDataFileCake)

        self.setDataOutput(xsDataResultSPD)