def populateXSDataInputSPDCake(self, _inputDict=None): self.DEBUG("EDPluginControlID11v1_0.populateXSDataInputSPDCake") xsDataInputSPDCake = XSDataInputSPDCake() if isinstance(_inputDict, dict): self.__dictID11 = _inputDict # Angle of tilt if "ANGLE OF TILT" in self.__dictID11: xsDataTilt = XSDataAngle() xsDataTilt.setValue(float(self.__dictID11["ANGLE OF TILT"])) xsDataTilt.setUnit(XSDataString("deg")) xsDataInputSPDCake.setAngleOfTilt(xsDataTilt) if "TILT ROTATION" in self.__dictID11: xsDataTiltRot = XSDataAngle() xsDataTiltRot.setValue(float(self.__dictID11["TILT ROTATION"])) xsDataTiltRot.setUnit(XSDataString("deg")) xsDataInputSPDCake.setTiltRotation(xsDataTiltRot) if "X-PIXEL SIZE" in self.__dictID11: xsDataXPixel = XSDataLength() xsDataXPixel.setValue(float(self.__dictID11["Y-PIXEL SIZE"])) xsDataXPixel.setUnit(XSDataString("micron")) xsDataInputSPDCake.setPixelSizeX(xsDataXPixel) if "Y-PIXEL SIZE" in self.__dictID11: xsDataYPixel = XSDataLength() xsDataYPixel.setValue(float(self.__dictID11["Y-PIXEL SIZE"])) xsDataYPixel.setUnit(XSDataString("micron")) xsDataInputSPDCake.setPixelSizeY(xsDataYPixel) if "DISTANCE" in self.__dictID11: xsDataDistance = XSDataLength() xsDataDistance.setValue(float(self.__dictID11["DISTANCE"])) xsDataDistance.setUnit(XSDataString("mm")) xsDataInputSPDCake.setSampleToDetectorDistance(xsDataDistance) if "WAVELENGTH" in self.__dictID11: xsDataWaweLength = XSDataWavelength() xsDataWaweLength.setValue(float(self.__dictID11["WAVELENGTH"])) xsDataWaweLength.setUnit(XSDataString("A")) xsDataInputSPDCake.setWavelength(xsDataWaweLength) if "DIM1_DATA" in self.__dictID11: xsDataBufferSizeX = XSDataInteger(int(self.__dictID11["DIM1_DATA"])) xsDataInputSPDCake.setBufferSizeX(xsDataBufferSizeX) if "DIM2_DATA" in self.__dictID11: xsDataBufferSizeY = XSDataInteger(int(self.__dictID11["DIM2_DATA"])) xsDataInputSPDCake.setBufferSizeY(xsDataBufferSizeY) # Dark current if ("DARK CURRENT" in self.__dictID11) and (self.__dictID11["DARK CURRENT"] == "YES") : if ("DC FILE" in self.__dictID11) and os.path.isfile(self.__dictID11["DC FILE"]): xsDataFile = XSDataFile() xsDataFile.setPath(XSDataString(self.__dictID11["DC FILE"])) xsDataInputSPDCake.setDarkCurrentImageFile(xsDataFile) else: self.warning("Asked for DC Current correction but no DC current file") if ("FLAT-FIELD" in self.__dictID11) and (self.__dictID11["FLAT-FIELD"] == "YES"): if ("FF FILE" in self.__dictID11) and os.path.isfile(self.__dictID11["FF FILE"]): xsDataFile = XSDataFile() xsDataFile.setPath(XSDataString(self.__dictID11["FF FILE"])) xsDataInputSPDCake.setFlatFieldImageFile(xsDataFile) else: self.warning("Asked for FLAT-FIELD correction but no FLAT-FIELD file") if ("MASK FILE" in self.__dictID11) and (self.__dictID11["USE MASK"] == "YES") : if ("MASK FILE" in self.__dictID11) and os.path.isfile(self.__dictID11["MASK FILE"]): xsDataFile = XSDataFile() xsDataFile.setPath(XSDataString(self.__dictID11["MASK FILE"])) xsDataInputSPDCake.setMaskFile(xsDataFile) else: self.warning("Asked for DC Current correction but no DC current file") if ("FF SCALE" in self.__dictID11) and (self.__dictID11["FF SCALE"] == "YES"): if ("FF MULTIPLIER" in self.__dictID11): try: value = float(self.__dictID11["FF MULTIPLIER"]) except Exception: self.warning("Asked for FF SCALE correction but FF MULTIPLIER provided (%s) in not float !" % (self.__dictID11["FF MULTIPLIER"])) else: xsDataInputSPDCake.setIntensityScaleFactor(XSDataDouble(1 / value)) else: self.warning("Asked for FF SCALE correction but no FF MULTIPLIER provided") if ("SPATIAL DIS." in self.__dictID11) and (self.__dictID11["SPATIAL DIS."] == "YES"): if ("SD FILE" in self.__dictID11) and os.path.isfile(self.__dictID11["SD FILE"]): xsDataFile = XSDataFile() xsDataFile.setPath(XSDataString(self.__dictID11["SD FILE"])) xsDataInputSPDCake.setSpatialDistortionFile(xsDataFile) else : self.warning("Asked for SPATIAL DISTORSION correction but no SPATIAL DISTORSION file") if "START AZIMUTH" in self.__dictID11: xsDataAzimuthStart = XSDataAngle() xsDataAzimuthStart.setValue(float(self.__dictID11["START AZIMUTH"])) xsDataAzimuthStart.setUnit(XSDataString("deg")) xsDataInputSPDCake.setStartAzimuth(xsDataAzimuthStart) if "END AZIMUTH" in self.__dictID11: xsDataAzimuthStop = XSDataAngle() xsDataAzimuthStop.setValue(float(self.__dictID11["END AZIMUTH"])) xsDataAzimuthStop.setUnit(XSDataString("deg")) xsDataInputSPDCake.setStopAzimuth(xsDataAzimuthStop) if "AZIMUTH BINS" in self.__dictID11: xsDataAzimuthStep = XSDataAngle() xsDataAzimuthStep.setValue((float(self.__dictID11["END AZIMUTH"]) - float(self.__dictID11["START AZIMUTH"])) / float(self.__dictID11["AZIMUTH BINS"])) xsDataAzimuthStep.setUnit(XSDataString("deg")) xsDataInputSPDCake.setStepAzimuth(xsDataAzimuthStep) if "INNER RADIUS" in self.__dictID11: xsDataInnerRadius = XSDataDouble() xsDataInnerRadius.setValue(float(self.__dictID11["INNER RADIUS"])) xsDataInputSPDCake.setInnerRadius(xsDataInnerRadius) if "OUTER RADIUS" in self.__dictID11: xsDataOuterRadius = XSDataDouble() xsDataOuterRadius.setValue(float(self.__dictID11["OUTER RADIUS"])) xsDataInputSPDCake.setOuterRadius(xsDataOuterRadius) if "X-BEAM CENTRE" in self.__dictID11: xsDataXBeamCentre = XSDataDouble() xsDataXBeamCentre.setValue(float(self.__dictID11["X-BEAM CENTRE"])) xsDataInputSPDCake.setBeamCentreInPixelsX(xsDataXBeamCentre) if "Y-BEAM CENTRE" in self.__dictID11: xsDataYBeamCentre = XSDataDouble() xsDataYBeamCentre.setValue(float(self.__dictID11["Y-BEAM CENTRE"])) xsDataInputSPDCake.setBeamCentreInPixelsY(xsDataYBeamCentre) # if "saving_format" in self.__dictID11: # xsSaveFormat = XSDataString() # if self.__dictID11["saving_format"] == "SPREAD SHEET": # xsSaveFormat.setValue("spr") # elif self.__dictID11["saving_format"] == "CIF": # xsSaveFormat.setValue("cif") # elif self.__dictID11["saving_format"] == "CHIPLOT": # xsSaveFormat.setValue("chi") # else: # xsSaveFormat.setValue("edf") # xsDataInputSPDCake.setOutputFileType(xsSaveFormat) if "output_dir" in self.__dictID11: xsOutputDir = XSDataFile() xsOutputDir.setPath(XSDataString(self.__dictID11["output_dir"])) xsDataInputSPDCake.setOutputDir(xsOutputDir) #Default options to SPD xsDataInputSPDCake.setOutputFileType(XSDataString("azim")) xsDataInputSPDCake.setDeleteCorImg(XSDataBoolean(not self.isVerboseDebug())) xsDataInputSPDCake.setCorrectTiltMask(XSDataBoolean(self.bCorrectMask)) return xsDataInputSPDCake
def doSuccessReadHeader(self, _edPlugin=None): EDVerbose.DEBUG("EDPluginControlDiffractionCTv1_1.doSuccessReadHeader") self.retrieveSuccessMessages(_edPlugin, "EDPluginControlDiffractionCTv1_1.doSuccessReadHeader") # Translate dictionary to image and instrument objects xsDataInputPowderIntegration = XSDataInputPowderIntegration() self.xsDataDiffractionCTInstrument = XSDataDiffractionCTInstrument() self.xsDataDiffractionCTImage = XSDataDiffractionCTImage() xsDataDictionaryHeader = self.edPluginReadHeader.getDataOutput().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) # if strUnit is None: strUnit = "A" # xsd.setUnit(XSDataString(strUnit)) self.xsDataDiffractionCTInstrument.set_diffrn_radiation_wavelength(xsd) elif (strKey == "_pd_instr_dist_spec/detc"): xsd = EDUtilsUnit.toXSD(XSDataLength, strValue) # if strUnit is None: strUnit = "mm" # xsd.setUnit(XSDataString(strUnit)) 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) # if strUnit is None: strUnit = "mm" # xsd.setUnit(XSDataString(strUnit)) self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_x(xsd) elif (strKey == "_tomo_spec_displ_x_inc"): xsd = EDUtilsUnit.toXSD(XSDataLength, strValue) # if strUnit is None: strUnit = "mm" # xsd.setUnit(XSDataString(strUnit)) 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.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.xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_max()) < pyintIndex + 1: # self.xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_max().append(None) # xsd = XSDataAngle(float(strValue)) # if strUnit is None: strUnit = "deg" # xsd.setUnit(XSDataString(strUnit)) # self.xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_max()[pyintIndex] = xsd # 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.xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_min()) < pyintIndex + 1: # self.xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_min().append(None) # xsd = XSDataAngle(float(strValue)) # if strUnit is None: strUnit = "deg" # xsd.setUnit(XSDataString(strUnit)) # self.xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_min()[pyintIndex] = 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) self.edPluginPowderIntegration.executeSynchronous()
def populateXSDataInputSPDCake(self, _inputDict=None): self.DEBUG("EDPluginControlID11v1_0.populateXSDataInputSPDCake") xsDataInputSPDCake = XSDataInputSPDCake() if isinstance(_inputDict, dict): self.__dictID11 = _inputDict # Angle of tilt if "ANGLE OF TILT" in self.__dictID11: xsDataTilt = XSDataAngle() xsDataTilt.setValue(float(self.__dictID11["ANGLE OF TILT"])) xsDataTilt.setUnit(XSDataString("deg")) xsDataInputSPDCake.setAngleOfTilt(xsDataTilt) if "TILT ROTATION" in self.__dictID11: xsDataTiltRot = XSDataAngle() xsDataTiltRot.setValue(float(self.__dictID11["TILT ROTATION"])) xsDataTiltRot.setUnit(XSDataString("deg")) xsDataInputSPDCake.setTiltRotation(xsDataTiltRot) if "X-PIXEL SIZE" in self.__dictID11: xsDataXPixel = XSDataLength() xsDataXPixel.setValue(float(self.__dictID11["Y-PIXEL SIZE"])) xsDataXPixel.setUnit(XSDataString("micron")) xsDataInputSPDCake.setPixelSizeX(xsDataXPixel) if "Y-PIXEL SIZE" in self.__dictID11: xsDataYPixel = XSDataLength() xsDataYPixel.setValue(float(self.__dictID11["Y-PIXEL SIZE"])) xsDataYPixel.setUnit(XSDataString("micron")) xsDataInputSPDCake.setPixelSizeY(xsDataYPixel) if "DISTANCE" in self.__dictID11: xsDataDistance = XSDataLength() xsDataDistance.setValue(float(self.__dictID11["DISTANCE"])) xsDataDistance.setUnit(XSDataString("mm")) xsDataInputSPDCake.setSampleToDetectorDistance(xsDataDistance) if "WAVELENGTH" in self.__dictID11: xsDataWaweLength = XSDataWavelength() xsDataWaweLength.setValue(float(self.__dictID11["WAVELENGTH"])) xsDataWaweLength.setUnit(XSDataString("A")) xsDataInputSPDCake.setWavelength(xsDataWaweLength) if "DIM1_DATA" in self.__dictID11: xsDataBufferSizeX = XSDataInteger(int( self.__dictID11["DIM1_DATA"])) xsDataInputSPDCake.setBufferSizeX(xsDataBufferSizeX) if "DIM2_DATA" in self.__dictID11: xsDataBufferSizeY = XSDataInteger(int( self.__dictID11["DIM2_DATA"])) xsDataInputSPDCake.setBufferSizeY(xsDataBufferSizeY) # Dark current if ("DARK CURRENT" in self.__dictID11) and (self.__dictID11["DARK CURRENT"] == "YES"): if ("DC FILE" in self.__dictID11) and os.path.isfile( self.__dictID11["DC FILE"]): xsDataFile = XSDataFile() xsDataFile.setPath(XSDataString(self.__dictID11["DC FILE"])) xsDataInputSPDCake.setDarkCurrentImageFile(xsDataFile) else: self.warning( "Asked for DC Current correction but no DC current file") if ("FLAT-FIELD" in self.__dictID11) and (self.__dictID11["FLAT-FIELD"] == "YES"): if ("FF FILE" in self.__dictID11) and os.path.isfile( self.__dictID11["FF FILE"]): xsDataFile = XSDataFile() xsDataFile.setPath(XSDataString(self.__dictID11["FF FILE"])) xsDataInputSPDCake.setFlatFieldImageFile(xsDataFile) else: self.warning( "Asked for FLAT-FIELD correction but no FLAT-FIELD file") if ("MASK FILE" in self.__dictID11) and (self.__dictID11["USE MASK"] == "YES"): if ("MASK FILE" in self.__dictID11) and os.path.isfile( self.__dictID11["MASK FILE"]): xsDataFile = XSDataFile() xsDataFile.setPath(XSDataString(self.__dictID11["MASK FILE"])) xsDataInputSPDCake.setMaskFile(xsDataFile) else: self.warning( "Asked for DC Current correction but no DC current file") if ("FF SCALE" in self.__dictID11) and (self.__dictID11["FF SCALE"] == "YES"): if ("FF MULTIPLIER" in self.__dictID11): try: value = float(self.__dictID11["FF MULTIPLIER"]) except Exception: self.warning( "Asked for FF SCALE correction but FF MULTIPLIER provided (%s) in not float !" % (self.__dictID11["FF MULTIPLIER"])) else: xsDataInputSPDCake.setIntensityScaleFactor( XSDataDouble(1 / value)) else: self.warning( "Asked for FF SCALE correction but no FF MULTIPLIER provided" ) if ("SPATIAL DIS." in self.__dictID11) and (self.__dictID11["SPATIAL DIS."] == "YES"): if ("SD FILE" in self.__dictID11) and os.path.isfile( self.__dictID11["SD FILE"]): xsDataFile = XSDataFile() xsDataFile.setPath(XSDataString(self.__dictID11["SD FILE"])) xsDataInputSPDCake.setSpatialDistortionFile(xsDataFile) else: self.warning( "Asked for SPATIAL DISTORSION correction but no SPATIAL DISTORSION file" ) if "START AZIMUTH" in self.__dictID11: xsDataAzimuthStart = XSDataAngle() xsDataAzimuthStart.setValue(float( self.__dictID11["START AZIMUTH"])) xsDataAzimuthStart.setUnit(XSDataString("deg")) xsDataInputSPDCake.setStartAzimuth(xsDataAzimuthStart) if "END AZIMUTH" in self.__dictID11: xsDataAzimuthStop = XSDataAngle() xsDataAzimuthStop.setValue(float(self.__dictID11["END AZIMUTH"])) xsDataAzimuthStop.setUnit(XSDataString("deg")) xsDataInputSPDCake.setStopAzimuth(xsDataAzimuthStop) if "AZIMUTH BINS" in self.__dictID11: xsDataAzimuthStep = XSDataAngle() xsDataAzimuthStep.setValue( (float(self.__dictID11["END AZIMUTH"]) - float(self.__dictID11["START AZIMUTH"])) / float(self.__dictID11["AZIMUTH BINS"])) xsDataAzimuthStep.setUnit(XSDataString("deg")) xsDataInputSPDCake.setStepAzimuth(xsDataAzimuthStep) if "INNER RADIUS" in self.__dictID11: xsDataInnerRadius = XSDataDouble() xsDataInnerRadius.setValue(float(self.__dictID11["INNER RADIUS"])) xsDataInputSPDCake.setInnerRadius(xsDataInnerRadius) if "OUTER RADIUS" in self.__dictID11: xsDataOuterRadius = XSDataDouble() xsDataOuterRadius.setValue(float(self.__dictID11["OUTER RADIUS"])) xsDataInputSPDCake.setOuterRadius(xsDataOuterRadius) if "X-BEAM CENTRE" in self.__dictID11: xsDataXBeamCentre = XSDataDouble() xsDataXBeamCentre.setValue(float(self.__dictID11["X-BEAM CENTRE"])) xsDataInputSPDCake.setBeamCentreInPixelsX(xsDataXBeamCentre) if "Y-BEAM CENTRE" in self.__dictID11: xsDataYBeamCentre = XSDataDouble() xsDataYBeamCentre.setValue(float(self.__dictID11["Y-BEAM CENTRE"])) xsDataInputSPDCake.setBeamCentreInPixelsY(xsDataYBeamCentre) # if "saving_format" in self.__dictID11: # xsSaveFormat = XSDataString() # if self.__dictID11["saving_format"] == "SPREAD SHEET": # xsSaveFormat.setValue("spr") # elif self.__dictID11["saving_format"] == "CIF": # xsSaveFormat.setValue("cif") # elif self.__dictID11["saving_format"] == "CHIPLOT": # xsSaveFormat.setValue("chi") # else: # xsSaveFormat.setValue("edf") # xsDataInputSPDCake.setOutputFileType(xsSaveFormat) if "output_dir" in self.__dictID11: xsOutputDir = XSDataFile() xsOutputDir.setPath(XSDataString(self.__dictID11["output_dir"])) xsDataInputSPDCake.setOutputDir(xsOutputDir) #Default options to SPD xsDataInputSPDCake.setOutputFileType(XSDataString("azim")) xsDataInputSPDCake.setDeleteCorImg( XSDataBoolean(not self.isVerboseDebug())) xsDataInputSPDCake.setCorrectTiltMask(XSDataBoolean(self.bCorrectMask)) return xsDataInputSPDCake
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)