예제 #1
0
    def setup(self, _listInput=[], _mode="offline"):
        """Configure the various options"""

        bOK = False
        if _listInput == []:
            _listInput = [os.getcwd()]
        while not bOK:
            strtmp = raw_input(
                "What are the input directories (mandatory, space separated) %s: "
                % _listInput).strip()
            if len(strtmp) > 0:
                bAllExists = True
                lstTemp = shlex.split(strtmp)
                for oneDir in shlex.split(strtmp):
                    if not os.path.exists(oneDir):
                        EDVerbose.screen("No such file or directory: %s" %
                                         oneDir)
                        bAllExists = False
                if bAllExists is True:
                    self.listInput = lstTemp
                    bOK = True
            else:
                self.listInput = _listInput
                bOK = True
        bOK = False
        while not bOK:
            strtmp = raw_input(
                "What is operation mode [offline|online|all] (mandatory: %s): "
                % _mode).strip().lower()
            if len(strtmp) > 0:
                bOK = True
                if strtmp == "offline":
                    self.bNewerOnly = False
                    self.strMode = "OffLine"
                elif strtmp == "online":
                    self.bNewerOnly = True
                    self.strMode = "dirwatch"
                elif strtmp == "all":
                    self.bNewerOnly = False
                    self.strMode = "dirwatch"
                else:
                    bOK = False

        bOK = False
        while not bOK:
            strtmp = raw_input(
                "What is the destination directory (mandatory): ").strip()
            if os.path.isdir(strtmp):
                self.destinationDirectory = XSDataFile()
                self.destinationDirectory.setPath(
                    XSDataString(os.path.abspath(strtmp)))
                bOK = True

        bOK = False
        while not bOK:
            strtmp = raw_input(
                "What is the sinogram filename prefix  (mandatory): ").strip()
            if strtmp != "":
                self.sinogramFileNamePrefix = XSDataString(strtmp)
                bOK = True

        bOK = False
        while not bOK:
            strtmp = raw_input(
                "What is the powder diffraction subdirectory  (mandatory): "
            ).strip()
            if strtmp != "":
                self.powderDiffractionSubdirectory = XSDataString(strtmp)
                bOK = True

        strtmp = raw_input(
            "What is the powder diffraction output format (CHI or CIF, if any ): "
        ).strip().lower()
        if strtmp.find("cif") >= 0:
            self.powderDiffractionFormat = XSDataString("cif")
        elif strtmp.find("chi") >= 0:
            self.powderDiffractionFormat = XSDataString("chi")

        strtmp = raw_input("Process all files ending with: ").strip()
        if len(strtmp) > 0:
            for oneExt in shlex.split(strtmp):
                self.listExtensions.append(oneExt)

        strtmp = raw_input("Exclude all files starting with: ").strip()
        if len(strtmp) > 0:
            for oneExt in shlex.split(strtmp):
                self.listExcludedPrefix.append(oneExt)

        strtmp = raw_input(
            "Do you want to over-ride metadata from the headers [y|N]: "
        ).strip().lower()
        if len(strtmp) > 0 and strtmp[0] == "y":

            strtmp = raw_input("What is the flat field image: ").strip()
            if os.path.isfile(strtmp):
                if self.forceImage is None:
                    self.forceImage = XSDataDiffractionCTImage()
                flatFieldImage = XSDataFile()
                flatFieldImage.setPath(XSDataString(os.path.abspath(strtmp)))
                self.forceImage.set_file_correction_image_flat_field(
                    flatFieldImage)

            strtmp = raw_input("What is the dark current image: ").strip()
            if os.path.isfile(strtmp):
                if self.forceImage is None:
                    self.forceImage = XSDataDiffractionCTImage()
                darkCurrentImage = XSDataFile()
                darkCurrentImage.setPath(XSDataString(os.path.abspath(strtmp)))
                self.forceImage.set_file_correction_image_dark_current(
                    darkCurrentImage)

            strtmp = raw_input("What is the mask file: ").strip()
            if os.path.isfile(strtmp):
                if self.forceImage is None:
                    self.forceImage = XSDataDiffractionCTImage()
                maskFile = XSDataFile()
                maskFile.setPath(XSDataString(strtmp))
                self.forceImage.set_file_correction_image_mask(maskFile)

            strtmp = raw_input("What is the spline file: ").strip()
            if os.path.isfile(strtmp):
                if self.forceImage is None:
                    self.forceImage = XSDataDiffractionCTImage()
                splineFile = XSDataFile()
                splineFile.setPath(XSDataString(os.path.abspath(strtmp)))
                self.forceImage.set_file_correction_spline_spatial_distortion(
                    splineFile)

            strtmp = raw_input(
                "What is the wavelength (like 0.7 A): ").replace(
                    "(", "").replace(")", "").strip()
            w = strtmp.split()
            if len(w) > 0:
                try:
                    f = float(w[0])
                except ValueError:
                    print("unable to understand what you said, skipping")
                else:
                    wavelength = XSDataWavelength()
                    wavelength.setValue(f)
                    if len(w) == 2:
                        wavelength.setUnit(XSDataString(w[1]))
                    if self.forceInstrument is None:
                        self.forceInstrument = XSDataDiffractionCTInstrument()
                    self.forceInstrument.set_diffrn_radiation_wavelength(
                        wavelength)

            strtmp = raw_input(
                "What is the distance between the sample and the detector along the beam: "
            ).replace("(", "").replace(")", "").strip()
            w = strtmp.split()
            if len(w) > 0:
                try:
                    f = float(w[0])
                except ValueError:
                    print("unable to understand what you said, skipping")
                else:
                    distance = XSDataLength()
                    distance.setValue(f)
                    if len(w) == 2:
                        distance.setUnit(XSDataString(w[1]))
                    if self.forceInstrument is None:
                        self.forceInstrument = XSDataDiffractionCTInstrument()
                    self.forceInstrument.set_pd_instr_dist_spec_detc(distance)

            strtmp = raw_input(
                "What is the pixel size (like 52.8 um 53.2 um): ").replace(
                    "(", "").replace(")", "").strip()
            w = strtmp.split()
            if len(w) > 0:
                xsdata1 = None
                xsdata2 = None
                if len(w) == 4:
                    try:
                        f1 = float(w[0])
                        f2 = float(w[2])
                    except ValueError:
                        print "Unable to convert to float !!! skipping"
                    else:
                        xsdata1 = XSDataLength()
                        xsdata1.setValue(f1)
                        xsdata1.setUnit(XSDataString(w[1]))
                        xsdata2 = XSDataLength()
                        xsdata2.setValue(f2)
                        xsdata2.setUnit(XSDataString(w[3]))
                elif len(w) == 2:
                    try:
                        f1 = float(w[0])
                        f2 = float(w[1])
                    except ValueError:
                        print "Unable to convert to float !!! skipping"
                    else:
                        xsdata1 = XSDataLength()
                        xsdata1.setValue(f1)
                        xsdata2 = XSDataLength()
                        xsdata2.setValue(f2)
                else:
                    print("unable to understand what you said, skipping")
                if (xsdata1 is not None) and (xsdata2 is not None):
                    if self.forceImage is None:
                        self.forceImage = XSDataDiffractionCTImage()
                    self.forceImage.set_array_element_size_1(xsdata1)
                    self.forceImage.set_array_element_size_2(xsdata2)

            strtmp = raw_input(
                "What is the beam center in distance, not pixels (like 53.5 mm 48.2 mm): "
            ).strip().replace("(", "").replace(")", "").strip()
            w = strtmp.split()
            if len(w) > 0:
                xsdata1 = None
                xsdata2 = None
                if len(w) == 4:
                    try:
                        f1 = float(w[0])
                        f2 = float(w[2])
                    except ValueError:
                        print "Unable to convert to float !!! skipping"
                    else:
                        xsdata1 = XSDataLength()
                        xsdata1.setValue(f1)
                        xsdata1.setUnit(XSDataString(w[1]))
                        xsdata2 = XSDataLength()
                        xsdata2.setValue(f2)
                        xsdata2.setUnit(XSDataString(w[3]))
                elif len(w) == 2:
                    try:
                        f1 = float(w[0])
                        f2 = float(w[1])
                    except ValueError, IndexError:
                        print "Unable to convert to float !!! skipping"
                    else:
                        xsdata1 = XSDataLength()
                        xsdata1.setValue(f1)
                        xsdata2 = XSDataLength()
                        xsdata2.setValue(f2)
                else:
                    print("unable to understand what you said, skipping")
                if (xsdata1 is not None) and (xsdata2 is not None):
                    if self.forceImage is None:
                        self.forceImage = XSDataDiffractionCTImage()
                    self.forceImage.set_diffrn_detector_element_center_1(
                        xsdata1)
                    self.forceImage.set_diffrn_detector_element_center_2(
                        xsdata2)

            strtmp = raw_input("What is the detector tilt angle: ").strip()
            tiltAngle = None
            try:
                tiltAngle = XSDataAngle(float(strtmp))
            except ValueError:
                print("unable to understand what you said, skipping")
            else:
                if self.forceImage is None:
                    self.forceImage = XSDataDiffractionCTImage()
                self.forceImage.set_pd_instr_special_details_tilt_angle(
                    tiltAngle)

            strtmp = raw_input("What is the tilt plan rotation: ").strip()
            tiltRotation = None
            try:
                tiltRotation = XSDataAngle(float(strtmp))
            except ValueError:
                print("unable to understand what you said, skipping")
            else:
                if self.forceImage is None:
                    self.forceImage = XSDataDiffractionCTImage()
                self.forceImage.set_pd_instr_special_details_tilt_rotation(
                    tiltRotation)

            strtmp = raw_input(
                "What is the number of fast motor steps (you will have n+1 points): "
            ).strip()
            try:
                self.fastMotorSteps = int(strtmp)
            except ValueError:
                fastMotorSteps = None
            else:
                if self.forceInstrument is None:
                    self.forceInstrument = XSDataDiffractionCTInstrument()
                self.forceInstrument.set_tomo_spec_displ_x_max(
                    XSDataLength(self.fastMotorSteps))
                self.forceInstrument.set_tomo_spec_displ_x_min(XSDataLength(0))
                self.forceInstrument.set_tomo_spec_displ_x_inc(XSDataLength(1))
                self.forceInstrument.set_tomo_scan_type(XSDataString("flat"))

            strtmp = raw_input(
                "What is the number of slow motor steps (you will have n+1 points): "
            ).strip()
            try:
                self.slowMotorSteps = int(strtmp)
            except ValueError:
                self.slowMotorSteps = None
            else:
                if self.forceInstrument is None:
                    self.forceInstrument = XSDataDiffractionCTInstrument()
                self.forceInstrument.set_tomo_scan_ampl(
                    XSDataLength(self.slowMotorSteps))
                self.forceInstrument.set_tomo_spec_displ_rotation_inc(
                    XSDataLength(1))
                self.forceInstrument.set_tomo_scan_type(XSDataString("flat"))

            strtmp = raw_input(
                "What is the index offset of your images: ").strip()
            try:
                self.indexOffset = int(strtmp)
            except ValueError:
                print("unable to understand what you said, skipping")
예제 #2
0
    def doSuccessReadHeader(self, _edPlugin=None):
        EDVerbose.DEBUG(
            "*** EDPluginControlDiffractionCTv1_0.doSuccessReadHeader")
        self.retrieveSuccessMessages(
            _edPlugin, "EDPluginControlDiffractionCTv1_0.doSuccessReadHeader")
        # Translate dictionary to image and instrument objects
        xsDataInputPowderIntegration = XSDataInputPowderIntegration()
        self.m_xsDataDiffractionCTInstrument = XSDataDiffractionCTInstrument()
        self.m_xsDataDiffractionCTImage = XSDataDiffractionCTImage()
        xsDataDictionaryHeader = self.m_edPluginReadHeader.getDataOutput(
        ).getDictionary()
        for xsDataKeyValuePair in xsDataDictionaryHeader.getKeyValuePair():
            strKey = str(xsDataKeyValuePair.getKey().getValue())
            strValue = str(xsDataKeyValuePair.getValue().getValue())
            if (strKey == "_diffrn_radiation_wavelength"):
                self.m_xsDataDiffractionCTInstrument.set_diffrn_radiation_wavelength(
                    XSDataWavelength(float(strValue)))
            elif (strKey == "_pd_instr_dist_spec/detc"):
                self.m_xsDataDiffractionCTInstrument.set_pd_instr_dist_spec_detc(
                    XSDataLength(float(strValue)))
            elif (strKey == "_pd_meas_2theta_range_max"):
                self.m_xsDataDiffractionCTInstrument.set_pd_meas_2theta_range_max(
                    XSDataAngle(float(strValue)))
            elif (strKey == "_pd_meas_2theta_range_min"):
                self.m_xsDataDiffractionCTInstrument.set_pd_meas_2theta_range_min(
                    XSDataAngle(float(strValue)))
            elif (strKey == "_pd_meas_2theta_range_inc"):
                self.m_xsDataDiffractionCTInstrument.set_pd_meas_2theta_range_inc(
                    XSDataAngle(float(strValue)))
            elif (strKey == "_synchrotron_photon-flux"):
                self.m_xsDataDiffractionCTInstrument.set_synchrotron_photon_flux(
                    XSDataFlux(float(strValue)))
            elif (strKey == "_synchrotron_ring-intensity"):
                self.m_xsDataDiffractionCTInstrument.set_synchrotron_ring_intensity(
                    XSDataDouble(float(strValue)))
            elif (strKey == "_tomo_scan_ampl"):
                self.m_xsDataDiffractionCTInstrument.set_tomo_scan_ampl(
                    XSDataAngle(float(strValue)))
            elif (strKey == "_tomo_scan_type"):
                self.m_xsDataDiffractionCTInstrument.set_tomo_scan_type(
                    XSDataString(strValue))
            elif (strKey == "_tomo_spec_displ_rotation"):
                self.m_xsDataDiffractionCTInstrument.set_tomo_spec_displ_rotation(
                    XSDataAngle(float(strValue)))
            elif (strKey == "_tomo_spec_displ_rotation_inc"):
                self.m_xsDataDiffractionCTInstrument.set_tomo_spec_displ_rotation_inc(
                    XSDataAngle(float(strValue)))
            elif (strKey == "_tomo_spec_displ_x"):
                self.m_xsDataDiffractionCTInstrument.set_tomo_spec_displ_x(
                    XSDataLength(float(strValue)))
            elif (strKey == "_tomo_spec_displ_x_inc"):
                self.m_xsDataDiffractionCTInstrument.set_tomo_spec_displ_x_inc(
                    XSDataLength(float(strValue)))
            elif (strKey == "_tomo_spec_displ_x_max"):
                self.m_xsDataDiffractionCTInstrument.set_tomo_spec_displ_x_max(
                    XSDataLength(float(strValue)))
            elif (strKey == "_tomo_spec_displ_x_min"):
                self.m_xsDataDiffractionCTInstrument.set_tomo_spec_displ_x_min(
                    XSDataLength(float(strValue)))
            elif (strKey == "_tomo_spec_displ_z"):
                self.m_xsDataDiffractionCTInstrument.set_tomo_spec_displ_z(
                    XSDataLength(float(strValue)))
            elif (strKey == "_tomo_spec_displ_z_inc"):
                self.m_xsDataDiffractionCTInstrument.set_tomo_spec_displ_z_inc(
                    XSDataLength(float(strValue)))
            elif (strKey == "_tomo_spec_displ_z_max"):
                self.m_xsDataDiffractionCTInstrument.set_tomo_spec_displ_z_max(
                    XSDataLength(float(strValue)))
            elif (strKey == "_tomo_spec_displ_z_min"):
                self.m_xsDataDiffractionCTInstrument.set_tomo_spec_displ_z_min(
                    XSDataLength(float(strValue)))
            elif (strKey == "_pd_instr_special_details_tilt_angle"):
                self.m_xsDataDiffractionCTImage.set_pd_instr_special_details_tilt_angle(
                    XSDataAngle(float(strValue)))
            elif (strKey == "_pd_instr_special_details_tilt_rotation"):
                self.m_xsDataDiffractionCTImage.set_pd_instr_special_details_tilt_rotation(
                    XSDataAngle(float(strValue)))
            elif (strKey == "_array_element_size[1]"):
                self.m_xsDataDiffractionCTImage.set_array_element_size_1(
                    XSDataLength(float(strValue)))
            elif (strKey == "_array_element_size[2]"):
                self.m_xsDataDiffractionCTImage.set_array_element_size_2(
                    XSDataLength(float(strValue)))
            elif (strKey == "_diffrn_detector_element.center[1]"):
                self.m_xsDataDiffractionCTImage.set_diffrn_detector_element_center_1(
                    XSDataLength(float(strValue)))
            elif (strKey == "_diffrn_detector_element.center[2]"):
                self.m_xsDataDiffractionCTImage.set_diffrn_detector_element_center_2(
                    XSDataLength(float(strValue)))

## Here the tricky case of lists ....
#            elif strKey.startswith("_pd_sum_2theta_range_max"):
#                if strKey.find("[")>0:
#                    pyintIndex = int(strKey.split("[")[1].split("]")[0]) - 1 #gets the int that is between []
#                else:
#                    pyintIndex = 0
#                while len(self.m_xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_max()) < pyintIndex + 1:
#                    self.m_xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_max().append(None)
#                self.m_xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_max()[pyintIndex] = XSDataAngle(float(strValue))
#            elif strKey.startswith("_pd_sum_2theta_range_min"):
#                if strKey.find("[")>0:
#                    pyintIndex = int(strKey.split("[")[1].split("]")[0]) - 1 #gets the int that is between []
#                else:
#                    pyintIndex = 0
#                while len(self.m_xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_min()) < pyintIndex + 1:
#                    self.m_xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_min().append(None)
#                self.m_xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_min()[pyintIndex] = XSDataAngle(float(strValue))
##end  Seems OK 20091023
            elif (strKey == "_file_correction_image_dark-current"):
                xsDataFileDark = XSDataFile()
                xsDataFileDark.setPath(XSDataString(strValue))
                self.m_xsDataDiffractionCTImage.set_file_correction_image_dark_current(
                    xsDataFileDark)
            elif (strKey == "_file_correction_image_flat-field"):
                xsDataFileFlat = XSDataFile()
                xsDataFileFlat.setPath(XSDataString(strValue))
                self.m_xsDataDiffractionCTImage.set_file_correction_image_flat_field(
                    xsDataFileFlat)
            elif (strKey == "_file_correction_image-mask"):
                xsDataFileMask = XSDataFile()
                xsDataFileMask.setPath(XSDataString(strValue))
                self.m_xsDataDiffractionCTImage.set_file_correction_image_mask(
                    xsDataFileMask)
            elif (strKey == "_file_correction_spline_spatial-distortion"):
                xsDataFileSpatialDist = XSDataFile()
                xsDataFileSpatialDist.setPath(XSDataString(strValue))
                self.m_xsDataDiffractionCTImage.set_file_correction_spline_spatial_distortion(
                    xsDataFileSpatialDist)
        xsDataInputPowderIntegration.setImageParameters(
            self.m_xsDataDiffractionCTImage)
        xsDataInputPowderIntegration.setInstrumentParameters(
            self.m_xsDataDiffractionCTInstrument)
        xsDataInputPowderIntegration.setImageFile(self.m_xsDataFileInputImage)
        self.m_edPluginPowderIntegration.setDataInput(
            xsDataInputPowderIntegration)
        self.m_edPluginPowderIntegration.executeSynchronous()
    def doSuccessReadHeader(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginControlDiffractionCTv1_2.doSuccessReadHeader")
        self.retrieveSuccessMessages(_edPlugin, "EDPluginControlDiffractionCTv1_2.doSuccessReadHeader")
        # Translate dictionary to image and instrument objects
        xsDataInputPowderIntegration = XSDataInputPowderIntegration()
        self.xsDataDiffractionCTInstrument = XSDataDiffractionCTInstrument()
        self.xsDataDiffractionCTImage = XSDataDiffractionCTImage()
        xsdOut = _edPlugin.getDataOutput()
        if xsdOut is None:
            strErr = "EDPluginControlDiffractionCTv1_2.doSuccessReadHeader: xsdataResult is None"
            EDVerbose.ERROR(strErr)
            self.setFailure()
            raise RuntimeError(strErr)
        xsDataDictionaryHeader = xsdOut.getDictionary()
        for xsDataKeyValuePair in xsDataDictionaryHeader.getKeyValuePair():
            strKey = str(xsDataKeyValuePair.getKey().getValue())
            lstValue = xsDataKeyValuePair.getValue().getValue().split()
            if len(lstValue) == 2:
                strValue = lstValue[0]
                strUnit = lstValue[1]
            else:
                strValue = xsDataKeyValuePair.getValue().getValue()
                strUnit = None

            if (strKey == "_diffrn_radiation_wavelength"):
                xsd = EDUtilsUnit.toXSD(XSDataWavelength, strValue)
                self.xsDataDiffractionCTInstrument.set_diffrn_radiation_wavelength(xsd)
            elif (strKey == "_pd_instr_dist_spec/detc"):
                xsd = EDUtilsUnit.toXSD(XSDataLength, strValue)
                self.xsDataDiffractionCTInstrument.set_pd_instr_dist_spec_detc(xsd)
            elif (strKey == "_pd_meas_2theta_range_max"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_pd_meas_2theta_range_max(xsd)
            elif (strKey == "_pd_meas_2theta_range_min"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_pd_meas_2theta_range_min(xsd)
            elif (strKey == "_pd_meas_2theta_range_inc"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_pd_meas_2theta_range_inc(xsd)
            elif (strKey == "_synchrotron_photon-flux"):
                self.xsDataDiffractionCTInstrument.set_synchrotron_photon_flux(XSDataFlux(float(strValue)))
            elif (strKey == "_synchrotron_ring-intensity"):
                self.xsDataDiffractionCTInstrument.set_synchrotron_ring_intensity(XSDataDouble(float(strValue)))
            elif (strKey == "_tomo_scan_ampl"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_scan_ampl(xsd)
            elif (strKey == "_tomo_scan_type"):
                self.xsDataDiffractionCTInstrument.set_tomo_scan_type(XSDataString(strValue))
            elif (strKey == "_tomo_spec_displ_rotation"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_rotation(xsd)
            elif (strKey == "_tomo_spec_displ_rotation_inc"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_rotation_inc(xsd)
            elif (strKey == "_tomo_spec_displ_x"):
                xsd = EDUtilsUnit.toXSD(XSDataLength, strValue)
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_x(xsd)
            elif (strKey == "_tomo_spec_displ_x_inc"):
                xsd = EDUtilsUnit.toXSD(XSDataLength, strValue)
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_x_inc(xsd)
            elif (strKey == "_tomo_spec_displ_x_max"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_x_max(xsd)
            elif (strKey == "_tomo_spec_displ_x_min"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_x_min(xsd)
            elif (strKey == "_tomo_spec_displ_z"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_z(xsd)
            elif (strKey == "_tomo_spec_displ_z_inc"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_z_inc(xsd)
            elif (strKey == "_tomo_spec_displ_z_max"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_z_max(xsd)
            elif (strKey == "_tomo_spec_displ_z_min"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_z_min(xsd)
            elif (strKey == "_pd_instr_special_details_tilt_angle"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTImage.set_pd_instr_special_details_tilt_angle(xsd)
            elif (strKey == "_pd_instr_special_details_tilt_rotation"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTImage.set_pd_instr_special_details_tilt_rotation(xsd)
            elif (strKey == "_array_element_size[1]"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "m"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTImage.set_array_element_size_1(xsd)
            elif (strKey == "_array_element_size[2]"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "m"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTImage.set_array_element_size_2(xsd)
            elif (strKey == "_diffrn_detector_element.center[1]"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTImage.set_diffrn_detector_element_center_1(xsd)
            elif (strKey == "_diffrn_detector_element.center[2]"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTImage.set_diffrn_detector_element_center_2(xsd)
            elif (strKey == "_file_correction_image_dark-current"):
                    xsDataFileDark = XSDataFile()
                    xsDataFileDark.setPath(XSDataString(strValue))
                    self.xsDataDiffractionCTImage.set_file_correction_image_dark_current(xsDataFileDark)
            elif (strKey == "_file_correction_image_flat-field"):
                xsDataFileFlat = XSDataFile()
                xsDataFileFlat.setPath(XSDataString(strValue))
                self.xsDataDiffractionCTImage.set_file_correction_image_flat_field(xsDataFileFlat)
            elif (strKey == "_file_correction_image-mask"):
                xsDataFileMask = XSDataFile()
                xsDataFileMask.setPath(XSDataString(strValue))
                self.xsDataDiffractionCTImage.set_file_correction_image_mask(xsDataFileMask)
            elif (strKey == "_file_correction_spline_spatial-distortion"):
                xsDataFileSpatialDist = XSDataFile()
                xsDataFileSpatialDist.setPath(XSDataString(strValue))
                self.xsDataDiffractionCTImage.set_file_correction_spline_spatial_distortion(xsDataFileSpatialDist)

        if self.xsdForceImageParam is not None:
            self.forceImageParam(self.xsdForceImageParam)

        if self.xsdForceScanParam is not None:
            self.forceScanParam(self.xsdForceScanParam)


        xsDataInputPowderIntegration.setImageParameters(self.xsDataDiffractionCTImage)
        xsDataInputPowderIntegration.setInstrumentParameters(self.xsDataDiffractionCTInstrument)
        xsDataInputPowderIntegration.setImageFile(self.xsDataFileInputImage)


# Set the destination directory for output  XRPD file

        strDestinationDirectory = os.path.join(self.getDataInput().getDestinationDirectory().getPath().getValue(), \
                                               self.getDataInput().getPowderDiffractionSubdirectory().getValue())

        if self.xsDataDiffractionCTInstrument.get_tomo_scan_type().getValue().lower() in  ["flat", "spiral"]:
            pyintLineNumber = int(abs(self.xsDataDiffractionCTInstrument.get_tomo_spec_displ_rotation().getValue()) / self.xsDataDiffractionCTInstrument.get_tomo_spec_displ_rotation_inc().getValue())
        elif self.xsDataDiffractionCTInstrument.get_tomo_scan_type().getValue().lower() == "mapping": #I agree mappings are not sinograms but the really looks like, no ? 
            pyintLineNumber = int(abs(self.xsDataDiffractionCTInstrument.get_tomo_spec_displ_z().getValue() - self.xsDataDiffractionCTInstrument.get_tomo_spec_displ_z_min().getValue()) / self.xsDataDiffractionCTInstrument.get_tomo_spec_displ_z_inc().getValue())
        else:
            pyintLineNumber = None
        try:
            strDestinationDirectory = "%s%04i" % (strDestinationDirectory, pyintLineNumber)
        except TypeError:
            pass #if pyintLineNumber is none: do not add suffix


        xsDataInputPowderIntegration.setDestinationDir(XSDataFile(XSDataString(strDestinationDirectory)))
        self.edPluginPowderIntegration.setDataInput(xsDataInputPowderIntegration)