Example #1
0
    def postProcess(self, _edObject=None):
        """
        postProcess of the plugin EDPluginSPDCorrectv10.py:
        - convert to HDF if needed (to be implemented)
        - move images (if needed)
        - set result XML   
        """
        EDPluginExecProcess.postProcess(self)
        self.DEBUG("EDPluginSPDCorrectv10.postProcess")
        EDUtilsPath.createFolder(self.dictGeometry["OutputDir"])

        if self.getClassName() == "EDPluginSPDCorrectv10":

            strInputImagePathNoSfx = os.path.splitext(os.path.basename(self.pathToInputFile))[0]
            destFileBaseName = strInputImagePathNoSfx + self.dictGeometry["OutputFileType"]
            strOutputFilePath = os.path.join(self.dictGeometry["OutputDir"], destFileBaseName)
            if not self._bFireAndForget:
                if "corrected" in self.dictRes:
                    strTempFilePath = self.dictRes["corrected"]
                else:
                    strTempFilePath = os.path.join(self.getWorkingDirectory(), destFileBaseName)
                if self.dictGeometry["OutputFileType"].lower() in [".hdf5", ".nexus", ".h5", ".nx"]:
                    self.WARNING("HDF5/Nexus output is not yet implemented in the SPD plugin.")
                if os.path.exists(strOutputFilePath):
                    self.WARNING("Destination file exists, I will leave result file in %s." % strTempFilePath)
                    strOutputFilePath = strTempFilePath
                else:
                    shutil.move(strTempFilePath, strOutputFilePath)
            #        # Create the output data
            xsDataFile = XSDataFile()
            xsDataFile.setPath(XSDataString(strOutputFilePath))

            xsDataResultSPD = XSDataResultSPD()
            xsDataResultSPD.setCorrectedFile(xsDataFile)
            self.setDataOutput(xsDataResultSPD)
Example #2
0
    def getInputParameter(self):
        """
        Read all the input parameters and store them in instance variables called  self.dictGeometry and  self.pathToInputFile
        """
        self.DEBUG("EDPluginSPDCakev1_5.getInputParameter")
        EDPluginSPDCorrectv10.getInputParameter(self)
        if self.xsDataInputSPD.getStartAzimuth() is not None:
            if self.xsDataInputSPD.getStartAzimuth().getUnit() is not None:
                self.dictGeometry["StartAzimuth"] = EDUtilsUnit.getValue(self.xsDataInputSPD.getStartAzimuth(), "deg")
            else:
                self.WARNING("You did not specify the StartAzimuth Unit, Falling back to Deg (not Rad)")
                self.dictGeometry["StartAzimuth"] = self.xsDataInputSPD.getStartAzimuth().getValue()
        if self.xsDataInputSPD.getStopAzimuth() is not None:
            if self.xsDataInputSPD.getStopAzimuth().getUnit() is not None:
                self.dictGeometry["StopAzimuth"] = EDUtilsUnit.getValue(self.xsDataInputSPD.getStopAzimuth(), "deg")
            else:
                self.WARNING("You did not specify the StopAzimuth Unit, Falling back to Deg (not Rad)")
                self.dictGeometry["StopAzimuth"] = self.xsDataInputSPD.getStopAzimuth().getValue()
        if self.xsDataInputSPD.getStepAzimuth() is not None:
            if self.xsDataInputSPD.getStepAzimuth().getUnit() is not None:
                self.dictGeometry["StepAzimuth"] = EDUtilsUnit.getValue(self.xsDataInputSPD.getStepAzimuth(), "deg")
            else:
                self.WARNING("You did not specify the StepAzimuth Unit, Falling back to Deg (not Rad)")
                self.dictGeometry["StepAzimuth"] = self.xsDataInputSPD.getStepAzimuth().getValue()
        if self.xsDataInputSPD.getInnerRadius() is not None:
            self.dictGeometry["InnerRadius"] = self.xsDataInputSPD.getInnerRadius().getValue()
        if self.xsDataInputSPD.getOuterRadius() is not None:
            self.dictGeometry["OuterRadius"] = self.xsDataInputSPD.getOuterRadius().getValue()
        if self.xsDataInputSPD.getOutputDirCake() is not None:
            self.dictGeometry["OutputDirCake"] = self.xsDataInputSPD.getOutputDirCake().getPath().getValue()
            EDUtilsPath.createFolder(self.dictGeometry["OutputDirCake"])
            if self.dictGeometry["OutputDirCake"] != self.dictGeometry["OutputDir"]:
                self.setFireAndForget(False)
        else:
            self.dictGeometry["OutputDirCake"] = self.dictGeometry["OutputDir"]
        if self.xsDataInputSPD.getMaskFile() is not None:
            self.dictGeometry["MaskFile"] = self.xsDataInputSPD.getMaskFile().getPath().getValue()
            if not os.path.isfile(self.dictGeometry["MaskFile"]):
                self.ERROR("Mask file %s does not exist " % self.dictGeometry["MaskFile"])
                self.dictGeometry.pop("MaskFile")
        if self.xsDataInputSPD.getIntensityScaleFactor() is not None:
            self.dictGeometry["IntensityScaleFactor"] = self.xsDataInputSPD.getIntensityScaleFactor().getValue()

        if self.xsDataInputSPD.getDeleteCorImg() is not None:
            self.bDeleteCorImg = (self.xsDataInputSPD.getDeleteCorImg().getValue() in ["1", 1, "true", "True", True])
        if self.bDeleteCorImg:
            self.setFireAndForget(False)
        if self.xsDataInputSPD.getCorrectTiltMask() is not None:
            self.bCorrectTiltMask = bool(self.xsDataInputSPD.getCorrectTiltMask().getValue())
Example #3
0
    def postProcess(self, _edObject=None):
        """
        postProcess of the plugin EDPluginSPDCorrectv10.py:
        - convert to HDF if needed (to be implemented)
        - move images (if needed)
        - set result XML   
        """
        EDPluginExecProcess.postProcess(self)
        self.DEBUG("EDPluginSPDCorrectv10.postProcess")
        EDUtilsPath.createFolder(self.dictGeometry["OutputDir"])

        if self.getClassName() == "EDPluginSPDCorrectv10":

            strInputImagePathNoSfx = os.path.splitext(
                os.path.basename(self.pathToInputFile))[0]
            destFileBaseName = strInputImagePathNoSfx + self.dictGeometry[
                "OutputFileType"]
            strOutputFilePath = os.path.join(self.dictGeometry["OutputDir"],
                                             destFileBaseName)
            if not self._bFireAndForget:
                if "corrected" in self.dictRes:
                    strTempFilePath = self.dictRes["corrected"]
                else:
                    strTempFilePath = os.path.join(self.getWorkingDirectory(),
                                                   destFileBaseName)
                if self.dictGeometry["OutputFileType"].lower() in [
                        ".hdf5", ".nexus", ".h5", ".nx"
                ]:
                    self.WARNING(
                        "HDF5/Nexus output is not yet implemented in the SPD plugin."
                    )
                if os.path.exists(strOutputFilePath):
                    self.WARNING(
                        "Destination file exists, I will leave result file in %s."
                        % strTempFilePath)
                    strOutputFilePath = strTempFilePath
                else:
                    shutil.move(strTempFilePath, strOutputFilePath)

    #        # Create the output data
            xsDataFile = XSDataFile()
            xsDataFile.setPath(XSDataString(strOutputFilePath))

            xsDataResultSPD = XSDataResultSPD()
            xsDataResultSPD.setCorrectedFile(xsDataFile)
            self.setDataOutput(xsDataResultSPD)
Example #4
0
    def getInputParameter(self):
        """
        Read all the input parameters and store them in instance variables called  self.dictGeometry and  self.pathToInputFile
        """
        self.DEBUG("EDPluginSPDCakev1_5.getInputParameter")
        EDPluginSPDCorrectv10.getInputParameter(self)
        if self.xsDataInputSPD.getStartAzimuth() is not None:
            if self.xsDataInputSPD.getStartAzimuth().getUnit() is not None:
                self.dictGeometry["StartAzimuth"] = EDUtilsUnit.getValue(
                    self.xsDataInputSPD.getStartAzimuth(), "deg")
            else:
                self.WARNING(
                    "You did not specify the StartAzimuth Unit, Falling back to Deg (not Rad)"
                )
                self.dictGeometry[
                    "StartAzimuth"] = self.xsDataInputSPD.getStartAzimuth(
                    ).getValue()
        if self.xsDataInputSPD.getStopAzimuth() is not None:
            if self.xsDataInputSPD.getStopAzimuth().getUnit() is not None:
                self.dictGeometry["StopAzimuth"] = EDUtilsUnit.getValue(
                    self.xsDataInputSPD.getStopAzimuth(), "deg")
            else:
                self.WARNING(
                    "You did not specify the StopAzimuth Unit, Falling back to Deg (not Rad)"
                )
                self.dictGeometry[
                    "StopAzimuth"] = self.xsDataInputSPD.getStopAzimuth(
                    ).getValue()
        if self.xsDataInputSPD.getStepAzimuth() is not None:
            if self.xsDataInputSPD.getStepAzimuth().getUnit() is not None:
                self.dictGeometry["StepAzimuth"] = EDUtilsUnit.getValue(
                    self.xsDataInputSPD.getStepAzimuth(), "deg")
            else:
                self.WARNING(
                    "You did not specify the StepAzimuth Unit, Falling back to Deg (not Rad)"
                )
                self.dictGeometry[
                    "StepAzimuth"] = self.xsDataInputSPD.getStepAzimuth(
                    ).getValue()
        if self.xsDataInputSPD.getInnerRadius() is not None:
            self.dictGeometry[
                "InnerRadius"] = self.xsDataInputSPD.getInnerRadius().getValue(
                )
        if self.xsDataInputSPD.getOuterRadius() is not None:
            self.dictGeometry[
                "OuterRadius"] = self.xsDataInputSPD.getOuterRadius().getValue(
                )
        if self.xsDataInputSPD.getOutputDirCake() is not None:
            self.dictGeometry[
                "OutputDirCake"] = self.xsDataInputSPD.getOutputDirCake(
                ).getPath().getValue()
            EDUtilsPath.createFolder(self.dictGeometry["OutputDirCake"])
            if self.dictGeometry["OutputDirCake"] != self.dictGeometry[
                    "OutputDir"]:
                self.setFireAndForget(False)
        else:
            self.dictGeometry["OutputDirCake"] = self.dictGeometry["OutputDir"]
        if self.xsDataInputSPD.getMaskFile() is not None:
            self.dictGeometry["MaskFile"] = self.xsDataInputSPD.getMaskFile(
            ).getPath().getValue()
            if not os.path.isfile(self.dictGeometry["MaskFile"]):
                self.ERROR("Mask file %s does not exist " %
                           self.dictGeometry["MaskFile"])
                self.dictGeometry.pop("MaskFile")
        if self.xsDataInputSPD.getIntensityScaleFactor() is not None:
            self.dictGeometry[
                "IntensityScaleFactor"] = self.xsDataInputSPD.getIntensityScaleFactor(
                ).getValue()

        if self.xsDataInputSPD.getDeleteCorImg() is not None:
            self.bDeleteCorImg = (
                self.xsDataInputSPD.getDeleteCorImg().getValue()
                in ["1", 1, "true", "True", True])
        if self.bDeleteCorImg:
            self.setFireAndForget(False)
        if self.xsDataInputSPD.getCorrectTiltMask() is not None:
            self.bCorrectTiltMask = bool(
                self.xsDataInputSPD.getCorrectTiltMask().getValue())