def testCheckParameters(self): xsDataFileIntegratedIntensities = XSDataFile() xsDataFileIntegratedIntensities.setPath(XSDataString("/tmp/file.cif")) xsDataFileSinogramDirectory = XSDataFile() xsDataFileSinogramDirectory.setPath(XSDataString("/tmp")) xsDataString = XSDataString("FakeExample") xsDataInput = XSDataInputWriteSinogram() xsDataInput.setIntegratedIntensities(xsDataFileIntegratedIntensities) xsDataInput.setSinogramDirectory(xsDataFileSinogramDirectory) xsDataInput.setSinogramFileNamePrefix(xsDataString) edPluginExecDCTWriteSinogram = self.createPlugin() edPluginExecDCTWriteSinogram.setDataInput(xsDataInput) edPluginExecDCTWriteSinogram.checkParameters()
def testCheckParameters(self): EDVerbose.DEBUG( "EDTestCasePluginUnitControlDiffractionCTv1_0.testCheckParameters") xsDataInput = XSDataInputDiffractionCT() xsDataImage = XSDataImage() xsDataInput.setImage(xsDataImage) xsDataFile = XSDataFile() xsDataInput.setDestinationDirectory(xsDataFile) xsDataInput.setSinogramFileNamePrefix(XSDataString("FakePrefix")) xsDataInput.setPowderDiffractionSubdirectory(XSDataString("Powder")) edPluginControlDCTPowderIntegration = self.createPlugin() edPluginControlDCTPowderIntegration.setDataInput(xsDataInput) edPluginControlDCTPowderIntegration.checkParameters()
def preProcess(self, _edObject=None): EDPluginControl.preProcess(self) EDVerbose.DEBUG("*** EDPluginControlDiffractionCTv1_0.preProcess") # Load the execution plugin self.m_edPluginReadHeader = self.loadPlugin( self.m_strControlledPluginReadHeader) self.m_edPluginPowderIntegration = self.loadPlugin( self.m_strControlledPluginPowderIntegration) self.m_edPluginWriteSinogram = self.loadPlugin( self.m_strControlledPluginWriteSinogram) # Set the input data for the read header plugin xsDataInputReadHeader = XSDataInputReadHeader() xsdataStringPathToImage = self.getDataInput().getImage().getPath() self.m_xsDataFileInputImage = XSDataFile() self.m_xsDataFileInputImage.setPath(xsdataStringPathToImage) xsDataInputReadHeader.setInputFile(self.m_xsDataFileInputImage) self.m_edPluginReadHeader.setDataInput(xsDataInputReadHeader)
def doSuccessPowderIntegration(self, _edPlugin=None): EDVerbose.DEBUG( "*** EDPluginControlDiffractionCTv1_0.doSuccessPowderIntegration") self.retrieveSuccessMessages( _edPlugin, "EDPluginControlDiffractionCTv1_0.doSuccessPowderIntegration") self.m_xsDataResultDiffractionCT = XSDataResultDiffractionCT() # Copy file to final destination and add path to result object xsDataFileIntegratedIntensities = self.m_edPluginPowderIntegration.getDataOutput( ).getIntegratedIntensities() EDVerbose.DEBUG("Path to cif: " + xsDataFileIntegratedIntensities.getPath().getValue()) EDVerbose.DEBUG("%s" % xsDataFileIntegratedIntensities) if (xsDataFileIntegratedIntensities is not None): strOutputFilePath = xsDataFileIntegratedIntensities.getPath( ).getValue() strDestinationDirectory = self.getDataInput( ).getDestinationDirectory().getPath().getValue() strPowderDiffractionSubdirectory = self.getDataInput( ).getPowderDiffractionSubdirectory().getValue() if not os.path.isdir(strDestinationDirectory): os.mkdir(strDestinationDirectory) if self.m_xsDataDiffractionCTInstrument.get_tomo_scan_type( ).getValue().lower() in ["flat", "spiral"]: # pyintLineNumber = int( abs( float( self.cif[ "_tomo_spec_displ_rotation" ] ) / float( self.cif[ "_tomo_spec_displ_rotation_inc" ] ) ) ) pyintLineNumber = int( abs(self.m_xsDataDiffractionCTInstrument. get_tomo_spec_displ_rotation().getValue()) / self.m_xsDataDiffractionCTInstrument. get_tomo_spec_displ_rotation_inc().getValue()) elif self.m_xsDataDiffractionCTInstrument.get_tomo_scan_type( ).getValue().lower( ) == "mapping": #I agree mappings are not sinograms but the really looks like, no ? # pyintLineNumber = int( abs( ( float( self.cif[ "_tomo_spec_displ_z" ]) - float ( self.cif [ "_tomo_spec_displ_z_min" ] ) ) / float( self.cif["_tomo_spec_displ_z_inc"] ) ) ) pyintLineNumber = int( abs(self.m_xsDataDiffractionCTInstrument. get_tomo_spec_displ_z().getValue() - self.m_xsDataDiffractionCTInstrument. get_tomo_spec_displ_z_min().getValue()) / self.m_xsDataDiffractionCTInstrument. get_tomo_spec_displ_z_inc().getValue()) else: pyintLineNumber = None if pyintLineNumber is not None: pystrDestinationSubDir = "%s%04i" % ( strPowderDiffractionSubdirectory, pyintLineNumber) strDestinationDirectoryWithSub = os.path.join( strDestinationDirectory, pystrDestinationSubDir) strDestinationFilePath = os.path.join( strDestinationDirectoryWithSub, os.path.basename(strOutputFilePath)) if not os.path.isdir( os.path.join(strDestinationDirectoryWithSub)): os.mkdir(strDestinationDirectoryWithSub) EDVerbose.DEBUG("Full path should be now: %s" % strDestinationFilePath) else: EDVerbose.DEBUG( "No modification of the output directory: I was not able to determine on which line of the sinogram I am." ) strDestinationFilePath = os.path.abspath( os.path.join(strDestinationDirectory, EDUtilsFile.getBaseName(strOutputFilePath))) EDUtilsFile.copyFile(strOutputFilePath, strDestinationFilePath) xsDataFileDestination = XSDataFile() xsDataFileDestination.setPath(XSDataString(strDestinationFilePath)) self.m_xsDataResultDiffractionCT.setIntegratedIntensities( xsDataFileDestination) xsDataPathSinogramDirectory = XSDataFile() xsDataPathSinogramDirectory.setPath( XSDataString(strDestinationDirectory)) xsDataInputWriteSinogram = XSDataInputWriteSinogram() xsDataInputWriteSinogram.setSinogramDirectory( xsDataPathSinogramDirectory) xsDataInputWriteSinogram.setIntegratedIntensities( xsDataFileDestination) xsDataInputWriteSinogram.setSinogramFileNamePrefix( self.getDataInput().getSinogramFileNamePrefix()) self.m_edPluginWriteSinogram.setDataInput(xsDataInputWriteSinogram) self.m_edPluginWriteSinogram.executeSynchronous()
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()