def test_getIntensity(self): """ Tests for method `getIntensity`. """ phirhozThinFilm = PhirhozGeneratedCharacteristicThinFilm.PhirhozGeneratedCharacteristicThinFilm( ) phirhozThinFilm.path = get_current_module_path( __file__, "../../../test_data/results") phirhozThinFilm.basename = "SimulationMCXrayPhirhozTestCases_Cu_E500d0keV_N100000e" phirhozThinFilm.read() self.assertEquals(1, phirhozThinFilm.numberRegions) regionID = 0 atomicSymbol = "Cu" intensity = phirhozThinFilm.getIntensity( regionID, atomicSymbol, PhirhozGeneratedCharacteristicThinFilm.SUBSHELL_K) self.assertAlmostEquals(390.159, intensity, 6) intensity = phirhozThinFilm.getIntensity( regionID, atomicSymbol, PhirhozGeneratedCharacteristicThinFilm.SUBSHELL_L) self.assertAlmostEquals(13367.3, intensity, 6) intensity = phirhozThinFilm.getIntensity( regionID, atomicSymbol, PhirhozGeneratedCharacteristicThinFilm.SUBSHELL_M) self.assertAlmostEquals(0.0, intensity, 6)
def test_isOlderThan(self): filename = "empty" filepathRef = get_current_module_path( __file__, "../../test_data/serialization/") filepathRef = os.path.join(filepathRef, filename + '.ser') if not os.path.isfile(filepathRef): raise SkipTest filepath1 = os.path.join(self.tempPath, filename + '_1' + '.ser') time.sleep(1.0) shutil.copy(filepathRef, filepath1) filepath2 = os.path.join(self.tempPath, filename + '_2' + '.ser') time.sleep(1.0) shutil.copy(filepathRef, filepath2) filepath3 = os.path.join(self.tempPath, filename + '_3' + '.ser') time.sleep(1.0) shutil.copy(filepathRef, filepath3) self.serialization.setFilepath(filepath2) self.assertFalse(self.serialization.isOlderThan(filepath1)) self.assertFalse(self.serialization.isOlderThan(filepath2)) self.assertTrue(self.serialization.isOlderThan(filepath3)) filepath = "/casd/csadf/asdfsdaf/sadfsdaf.ser" self.assertFalse(self.serialization.isOlderThan(filepath)) filepath = "/casd/csadf/asdfsdaf/sadfsdaf.ser" self.serialization.setFilepath(filepath) self.assertTrue(self.serialization.isOlderThan(filepath3))
def test_read(self): """ Tests for method `read`. """ phirhozThinFilm = PhirhozGeneratedCharacteristicThinFilm.PhirhozGeneratedCharacteristicThinFilm( ) phirhozThinFilm.path = get_current_module_path( __file__, "../../../test_data/results") phirhozThinFilm.basename = "SimulationMCXrayPhirhozTestCases_Cu_E500d0keV_N100000e" phirhozThinFilm.read() self.assertEquals(1, phirhozThinFilm.numberRegions) intensity = phirhozThinFilm.intensities[0] self.assertEquals( "0", intensity[PhirhozGeneratedCharacteristicThinFilm.INDEX_REGION]) self.assertEquals( "Cu", intensity[PhirhozGeneratedCharacteristicThinFilm.ATOM_SYMBOL]) self.assertEquals( "390.159", intensity[PhirhozGeneratedCharacteristicThinFilm.SUBSHELL_K]) self.assertEquals( "13367.3", intensity[PhirhozGeneratedCharacteristicThinFilm.SUBSHELL_L]) self.assertEquals( "0", intensity[PhirhozGeneratedCharacteristicThinFilm.SUBSHELL_M])
def setUp(self): """ Setup method. """ unittest.TestCase.setUp(self) self.filepath = get_current_module_path( __file__, "../../../../test_data/exportedFiles/CNTsFePt_30keV_100e_100pixels_BF.txt" )
def test_isFile(self): filepathRef = "/casd/csadf/asdfsdaf/sadfsdaf.ser" self.serialization.setFilepath(filepathRef) self.assertFalse(self.serialization.isFile()) filepathRef = get_current_module_path( __file__, "../../test_data/serialization/empty.ser") if not os.path.isfile(filepathRef): raise SkipTest self.serialization.setFilepath(filepathRef) self.assertTrue(self.serialization.isFile())
def test_getIntensity(self): """ Tests for method `getIntensity`. """ phirhozThinFilm = PhirhozEmittedCharacteristicThinFilm.PhirhozEmittedCharacteristicThinFilm( ) phirhozThinFilm.path = get_current_module_path( __file__, "../../../test_data/results") phirhozThinFilm.basename = "SimulationMCXrayPhirhozTestCases_Cu_E500d0keV_N100000e" phirhozThinFilm.read() self.assertEquals(1, phirhozThinFilm.numberRegions) regionID = 0 atomicSymbol = "Cu" intensity = phirhozThinFilm.getIntensity( regionID, atomicSymbol, PhirhozEmittedCharacteristicThinFilm.LINE_KA1) self.assertAlmostEquals(0.00194507, intensity, 6) intensity = phirhozThinFilm.getIntensity( regionID, atomicSymbol, PhirhozEmittedCharacteristicThinFilm.LINE_KA2) self.assertAlmostEquals(0.00179503, intensity, 6) intensity = phirhozThinFilm.getIntensity( regionID, atomicSymbol, PhirhozEmittedCharacteristicThinFilm.LINE_KB1) self.assertAlmostEquals(0.0337762, intensity, 6) intensity = phirhozThinFilm.getIntensity( regionID, atomicSymbol, PhirhozEmittedCharacteristicThinFilm.LINE_KB2) self.assertAlmostEquals(0.0, intensity, 6) intensity = phirhozThinFilm.getIntensity( regionID, atomicSymbol, PhirhozEmittedCharacteristicThinFilm.LINE_LA) self.assertAlmostEquals(8.20759E-158, intensity, 6) intensity = phirhozThinFilm.getIntensity( regionID, atomicSymbol, PhirhozEmittedCharacteristicThinFilm.LINE_LB1) self.assertAlmostEquals(0.0, intensity, 6) intensity = phirhozThinFilm.getIntensity( regionID, atomicSymbol, PhirhozEmittedCharacteristicThinFilm.LINE_LB2) self.assertAlmostEquals(0.0, intensity, 6) intensity = phirhozThinFilm.getIntensity( regionID, atomicSymbol, PhirhozEmittedCharacteristicThinFilm.LINE_LG) self.assertAlmostEquals(0.0, intensity, 6) intensity = phirhozThinFilm.getIntensity( regionID, atomicSymbol, PhirhozEmittedCharacteristicThinFilm.LINE_MA) self.assertAlmostEquals(0.0, intensity, 6)
def run(): from pymcxray import get_current_module_path filepath = get_current_module_path( __file__, "../../../../test_data/exportedFiles/CNTsFePt_30keV_100e_100pixels_BF.txt" ) dataMap = DataMap(filepath) dataMap.read() dataMap.showImage() dataMap.saveImage()
def test_read(self): """ Tests for method `read`. """ spectrumFile = XraySimulatedSpectraSpecimen.XraySimulatedSpectraSpecimen() spectrumFile.path = get_current_module_path(__file__, "../../../test_data/results") spectrumFile.basename = "testC_10e_10kp" spectrumFile.read() self.assertEquals(1024, len(spectrumFile.energies_keV)) self.assertEquals(1024, len(spectrumFile.totals))
def test_read(self): """ Tests for method `read`. """ intensitiesFile = XrayIntensities.XrayIntensities() intensitiesFile.path = get_current_module_path( __file__, "../../../test_data/results") intensitiesFile.basename = "SimulationsFRatio_Al0d200000Cu0d800000_E5d0keV" intensitiesFile.read() self.assertEquals(5, intensitiesFile.numberIntensities)
def _createIgnoredItems(sectionName, configurationFile): configurationFilepath = get_current_module_path(__file__, configurationFile) values = read_value_from_configuration_file(configurationFilepath, "Testings", sectionName, default="") names = [] for item in values.split(','): names.append(item.strip()) return names
def run(): path = get_current_module_path(__file__, "../../../test_data/version1.2") filepath = os.path.join( path, "SimulationsComplexPhiRhoZ_Cr_T5nm_Z0nm_Al_E10d0keV_ElectronTrajectoriesResults.csv" ) #filepath = os.path.join(path, "SimulationsComplexPhiRhoZ_Cr100T50A_IsolatedLayer_E10d0keV_ElectronTrajectoriesResults.csv") electronTrajectoriesResults = ElectronTrajectoriesResults(filepath) electronTrajectoriesResults.drawXZ() electronTrajectoriesResults.drawXY() electronTrajectoriesResults.drawYZ() plt.show()
def test_deleteFile(self): filename = "empty.ser" filepathRef = get_current_module_path( __file__, "../../test_data/serialization/") filepathRef = os.path.join(filepathRef, filename) if not os.path.isfile(filepathRef): raise SkipTest filepath = os.path.join(self.tempPath, filename) shutil.copy2(filepathRef, filepath) self.serialization.setFilepath(filepath) self.assertTrue(os.path.isfile(filepath)) self.serialization.deleteFile() self.assertFalse(os.path.isfile(filepath))
def test_read(self): """ Tests for method `read`. """ spectrumFile = XraySpectraSpecimen.XraySpectraSpecimen() spectrumFile.path = get_current_module_path( __file__, "../../../test_data/results") spectrumFile.basename = "ExperimentalSpectraMCXRay_Au100T250000A_E200d0keV_N1000e_N21000000X_t600s_w20eV_N64W" spectrumFile.read() self.assertEquals(40000, len(spectrumFile.energies_keV)) self.assertEquals(40000, len(spectrumFile.totals)) self.assertEquals(40000, len(spectrumFile.characteristics)) self.assertEquals(40000, len(spectrumFile.backgrounds))
def test_read(self): """ Tests for method `read`. """ spectrumFile = XraySpectraSpecimenEmittedDetected.XraySpectraSpecimenEmittedDetected( ) spectrumFile.path = get_current_module_path( __file__, "../../../test_data/results") spectrumFile.basename = "SimulationsAuNPonC_Au_d100A_C_E10d0keV_N10000e_N1000000X" spectrumFile.read() self.assertEquals(2000, len(spectrumFile.energies_keV)) self.assertEquals(2000, len(spectrumFile.totals)) self.assertEquals(2000, len(spectrumFile.characteristics)) self.assertEquals(2000, len(spectrumFile.backgrounds))
def test_read(self): """ Tests for method `read`. """ #PhirhozMCXRay_Ag_E5d0keV_N10000e_tB0d0deg_TOA45d0deg_PhirhozEmittedCharacteristic_Region0.csv spectrumFile = PhirhozEmittedCharacteristic.PhirhozEmittedCharacteristic() spectrumFile.path = get_current_module_path(__file__, "../../../test_data/results") spectrumFile.basename = "PhirhozMCXRay_Ag_E5d0keV_N10000e_tB0d0deg_TOA45d0deg" regionID = 0 spectrumFile.read(regionID) self.assertEquals(5, len(spectrumFile.fieldNames)) self.assertEquals(128, len(spectrumFile.depth_A)) self.assertEquals(4, len(spectrumFile.phirhozs)) self.assertEquals(128, len(spectrumFile.phirhozs[("Ag", "La")]))
def run(): import pymcxray.BatchFileConsole as BatchFileConsole configurationFilepath = get_current_module_path(__file__, "../../MCXRay_latest.cfg") programName = get_mcxray_program_name(configurationFilepath) batchFile = BatchFileConsole.BatchFileConsole( "BatchSimulationTestLinescansMM2017", programName, numberFiles=10) analyze = SimulationTestLinescansMM2017( relativePath=r"mcxray/SimulationTestLinescansMM2017", configurationFilepath=configurationFilepath) analyze.overwrite = False analyze.run(batchFile) plt.show()
def run(): # import the batch file class. from pymcxray.BatchFileConsole import BatchFileConsole # Find the configuration file path configuration_file_path = get_current_module_path(__file__, "MCXRay_latest.cfg") program_name = get_mcxray_program_name(configuration_file_path) # Create the batch file object. batch_file = BatchFileConsole("BatchSimulationTestMapsMM2017", program_name, numberFiles=6) # Create the simulation object and add the batch file object to it. analyze = SimulationTestMapsMM2017( relativePath=r"mcxray/SimulationTestMapsMM2017", configurationFilepath=configuration_file_path) analyze.run(batch_file)
def test_read(self): """ Tests for method `read`. """ phirhozThinFilm = PhirhozEmittedCharacteristicThinFilm.PhirhozEmittedCharacteristicThinFilm( ) phirhozThinFilm.path = get_current_module_path( __file__, "../../../test_data/results") phirhozThinFilm.basename = "SimulationMCXrayPhirhozTestCases_Cu_E500d0keV_N100000e" phirhozThinFilm.read() self.assertEquals(1, phirhozThinFilm.numberRegions) intensity = phirhozThinFilm.intensities[0] self.assertEquals( "0", intensity[PhirhozEmittedCharacteristicThinFilm.INDEX_REGION]) self.assertEquals( "Cu", intensity[PhirhozEmittedCharacteristicThinFilm.ATOM_SYMBOL]) self.assertEquals( "0.00194507", intensity[PhirhozEmittedCharacteristicThinFilm.LINE_KA1]) self.assertEquals( "0.00179503", intensity[PhirhozEmittedCharacteristicThinFilm.LINE_KA2]) self.assertEquals( "0.0337762", intensity[PhirhozEmittedCharacteristicThinFilm.LINE_KB1]) self.assertEquals( "0", intensity[PhirhozEmittedCharacteristicThinFilm.LINE_KB2]) self.assertEquals( "8.20759e-158", intensity[PhirhozEmittedCharacteristicThinFilm.LINE_LA]) self.assertEquals( "0", intensity[PhirhozEmittedCharacteristicThinFilm.LINE_LB1]) self.assertEquals( "0", intensity[PhirhozEmittedCharacteristicThinFilm.LINE_LB2]) self.assertEquals( "0", intensity[PhirhozEmittedCharacteristicThinFilm.LINE_LG]) self.assertEquals( "0", intensity[PhirhozEmittedCharacteristicThinFilm.LINE_MA])
def test_read(self): """ Tests for method `read`. """ spectrumFile = XraySimulatedSpectraRegion.XraySimulatedSpectraRegion() spectrumFile.path = get_current_module_path( __file__, "../../../test_data/results") spectrumFile.basename = "testC_10e_10kp" spectrumFile.read() self.assertEquals(1024, len(spectrumFile.channelNumbers)) self.assertEquals(1024, len(spectrumFile.energiesReference_keV)) self.assertEquals(1024, len(spectrumFile.energies_keV)) self.assertEquals(1024, len(spectrumFile.simulatedIntensities)) self.assertEquals(1024, len(spectrumFile.detectedIntensities)) self.assertEquals(1024, len(spectrumFile.eNetPeak[0])) self.assertEquals(1024, len(spectrumFile.peakToBackgrpound)) self.assertEquals(1024, len(spectrumFile.peakToBackgrpoundAverage))
def test_read(self): """ Tests for method `read`. """ #SimulationsAuNPonCExperimental_Au_d61A_C_E5d0keV_N10000e_N1000X_SpectraAtomEmittedDetectedLines_Region1.csv spectrumFile = XraySpectraAtomEmittedDetectedLines.XraySpectraAtomEmittedDetectedLines( ) spectrumFile.path = get_current_module_path( __file__, "../../../test_data/results") spectrumFile.basename = "SimulationsAuNPonCExperimental_Au_d61A_C_E5d0keV_N10000e_N1000X" regionID = 1 spectrumFile.read(regionID) self.assertEquals(0.0025, spectrumFile.energies_keV[0]) self.assertEquals(4.9975, spectrumFile.energies_keV[-1]) self.assertEquals(1000, len(spectrumFile.energies_keV)) self.assertEquals(1, len(spectrumFile.characteristics)) self.assertEquals(1000, len(spectrumFile.characteristics['Au']))
def __init__(self, simulationPath=None, basepath=None, relativePath=None, configurationFilepath=None): if configurationFilepath is None: self._configurationFilepath = get_current_module_path(__file__, "../../pyMcGill.cfg") else: self._configurationFilepath = configurationFilepath self._output = None self.overwrite = True self.resetCache = False self.useSerialization = True self.verbose = True self.createBackup = True self.use_hdf5 = False self.delete_result_files = False self.read_interval_h = 1 self.read_interval_m = None if simulationPath is not None: self._simulationPath = os.path.normpath(simulationPath) else: self._simulationPath = None if basepath is not None: self._basepath = os.path.normpath(basepath) else: self._basepath = None if relativePath is not None: self._relativePath = os.path.normpath(relativePath) else: self._relativePath = None self._createAllFolders(self.getSimulationPath()) self._simulationResultsList = {} self._serializationExtension = '.ser' self.format_digit = {}
def run(): simulation_name = "SimulationTrainingMapsMM2017_Fe075" elements = [(26, 0.75), (27, 0.25)] # import the batch file class. from pymcxray.BatchFileConsole import BatchFileConsole # Find the configuration file path configuration_file_path = get_current_module_path(__file__, "MCXRay_latest.cfg") program_name = get_mcxray_program_name(configuration_file_path) # Create the batch file object. batch_file = BatchFileConsole("BatchSimulationTrainingMapsMM2017", program_name, numberFiles=10) # Create the simulation object and add the batch file object to it. analyze = SimulationTrainingMapsMM2017( simulation_name, elements, relativePath=r"mcxray/SimulationTrainingMapsMM2017", configurationFilepath=configuration_file_path) analyze.run(batch_file)
def test_read(self): """ Tests for method `read`. """ electronResults = ElectronResults.ElectronResults() electronResults.path = get_current_module_path( __file__, "../../../test_data/results") electronResults.basename = "SimulationKalefEzra1982_Al100T10000A_E300d0keV_N100000e" electronResults.read() self.assertEquals(100000, electronResults.numberSimulatedElectrons) self.assertEquals(0, electronResults.numberInternalElectrons) self.assertEquals(43, electronResults.numberBackscatteredElectrons) self.assertEquals(99956, electronResults.numberTransmittedElectrons) self.assertEquals(0, electronResults.numberSkirtedElectrons) self.assertEquals(458571, electronResults.numberElectronCollisions) self.assertEquals(0, electronResults.fractionInternalElectrons) self.assertEquals(0.00043, electronResults.fractionBackscatteredElectrons) self.assertEquals(0.99956, electronResults.fractionTransmittedElectrons) self.assertEquals(0, electronResults.fractionSkirtedElectrons)