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 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 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()