Example #1
0
    def test_read(self):
        """
        Tests for method `read`.
        """

        for title in testUtilities.getSimulationTitles():
            logging.info(title)

            specimen = Specimen.Specimen()

            filepath = os.path.abspath(os.path.join(self.testDataPath, "%s/%s.sam" % (title, title)))
            specimen.read(filepath)

            self.assertEquals(Version.VERSION_1_1_1.major, specimen.version.major)
            self.assertEquals(Version.VERSION_1_1_1.minor, specimen.version.minor)
            self.assertEquals(Version.VERSION_1_1_1.revision, specimen.version.revision)
            self.assertEquals(Version.VERSION_1_1_1, specimen.version)

            specimenRef = self.getSpecimenReference(title)

            self.assertEquals(specimenRef.version.major, specimen.version.major)
            self.assertEquals(specimenRef.version.minor, specimen.version.minor, title)
            self.assertEquals(specimenRef.version.revision, specimen.version.revision)
            self.assertEquals(specimenRef.version, specimen.version)

            self.assertEquals(specimenRef.numberRegions, specimen.numberRegions)
    def test_write(self):
        """
        Tests for method `write`.
        """
        raise SkipTest

        self.maxDiff = None

        for title in testUtilities.getSimulationTitles():
            resultsParametersRef = self.getSimulationParametersReference(title)

            filepathReference = os.path.abspath(os.path.join(self.testDataPath, "%s/%s.rp" % (title, title)))

            filepath = os.path.join(self.tempDataPath, "%s.rp" % (title))
            resultsParameters = ResultsParameters.ResultsParameters()
            resultsParameters = resultsParametersRef

            resultsParameters.write(filepath)

            self.assertEquals(resultsParametersRef.isComputeXrayCharacteristic, resultsParameters.isComputeXrayCharacteristic)
            self.assertEquals(resultsParametersRef.isComputeXrayBremsstrahlung, resultsParameters.isComputeXrayBremsstrahlung)
            self.assertEquals(resultsParametersRef.isComputeXrayPhirhoz, resultsParameters.isComputeXrayPhirhoz)

            linesRef = open(filepathReference, 'r').readlines()
            lines = open(filepath, 'r').readlines()

            self.assertListEqual(linesRef, lines)

        self.fail("Test if the testcase is working.")
Example #3
0
    def test_write(self):
        """
        Tests for method `write`.
        """
        raise SkipTest

        self.maxDiff = None

        for title in testUtilities.getSimulationTitles():
            logging.info(title)

            specimenRef = self.getSpecimenReference(title)
            filepathReference = os.path.abspath(os.path.join(self.testDataPath, "%s/%s.sam" % (title, title)))

            filepath = os.path.join(self.tempDataPath, "%s.sam" % (title))

            specimen = Specimen.Specimen()
            specimen = specimenRef

            specimen.write(filepath)

            linesRef = open(filepathReference, 'r').readlines()
            lines = open(filepath, 'r').readlines()

            for index in range(len(linesRef)):
                lineRef = linesRef[index]
                line = lines[index]
                message = "%i:\n%s\n%s" % (index, lineRef, line)
                self.assertEquals(lineRef, line, message)

            self.assertListEqual(linesRef, lines)
Example #4
0
    def test_read(self):
        """
        Tests for method `read`.
        """

        models = Models.Models()

        for title in testUtilities.getSimulationTitles():
            filepath = os.path.abspath(
                os.path.join(self.testDataPath, "%s/%s.mdl" % (title, title)))
            models.read(filepath)

            modelList = models.getModelList()
            self.assertEquals(self.numberModels, len(modelList))

            self.assertEquals(
                MCXRayModel.AtomMeanIonizationPotentialModel.TYPE_JOY_LUO,
                modelList[Models.
                          KEY_ATOM_MEAN_IONIZATION_POTENTIAL_MODEL].getModel())
            self.assertEquals(
                MCXRayModel.AtomEnergyLossModel.TYPE_BETHE,
                modelList[Models.KEY_ATOM_ENERGY_LOSS_MODEL].getModel())
            self.assertEquals(
                MCXRayModel.AtomScreeningModel.TYPE_HENOC_MAURICE,
                modelList[Models.KEY_ATOM_SCREENING_MODEL].getModel())
            self.assertEquals(
                MCXRayModel.AtomCrossSectionModel.TYPE_BROWNING,
                modelList[Models.KEY_ATOM_CROSS_SECTION_MODEL].getModel())
            self.assertEquals(
                MCXRayModel.AtomCrossSectionScreeningModel.TYPE_HENOC_MAURICE,
                modelList[
                    Models.KEY_ATOM_CROSS_SECTION_SCREENING_MODEL].getModel())
            self.assertEquals(
                MCXRayModel.AtomCollisionModel.TYPE_BROWNING,
                modelList[Models.KEY_ATOM_COLLISION_MODEL].getModel())
            self.assertEquals(
                MCXRayModel.AtomCollisionScreeningModel.TYPE_HENOC_MAURICE,
                modelList[
                    Models.KEY_ATOM_COLLISION_SCREENING_MODEL].getModel())
            self.assertEquals(
                MCXRayModel.AtomElectronRangeModel.TYPE_KANAYA_OKAYAMA,
                modelList[Models.KEY_ATOM_ELECTRON_RANGE_MODEL].getModel())
            self.assertEquals(
                MCXRayModel.XRayCSCharacteristicModel.TYPE_CASTANI1982,
                modelList[Models.KEY_XRAY_CS_CHARACTERISTIC_MODEL].getModel())
            self.assertEquals(
                MCXRayModel.XRayCSBremsstrahlungModel.TYPE_DING,
                modelList[Models.KEY_XRAY_CS_BREMSSTRAHLUNG_MODEL].getModel())
            self.assertEquals(
                MCXRayModel.SampleEnergyLossModel.TYPE_BETHE_JOY_LUO,
                modelList[Models.KEY_SAMPLE_ENERGY_LOSS_MODEL].getModel())
            self.assertEquals(
                MCXRayModel.RegionEnergyLossModel.TYPE_BETHE_JOY_LUO,
                modelList[Models.KEY_REGION_ENERGY_LOSS_MODEL].getModel())
            self.assertEquals(
                MCXRayModel.MassAbsorptionCoefficientModel.TYPE_CHANTLER2005,
                modelList[
                    Models.KEY_MASS_ABSORPTION_COEFFICIENT_MODEL].getModel())
Example #5
0
    def test__extractTitleFromFilepath(self):
        """
        Tests for method `_extractTitleFromFilepath`.
        """

        simulationInputs = SimulationInputs.SimulationInputs()

        for titleRef in testUtilities.getSimulationTitles():
            filepath = os.path.abspath(
                os.path.join(self.testDataPath,
                             "%s/%s.sim" % (titleRef, titleRef)))
            title = simulationInputs._extractTitleFromFilepath(filepath)

            self.assertEquals(titleRef, title)
    def test_write(self):
        """
        Tests for method `write`.
        """
        raise SkipTest

        self.maxDiff = None

        for title in testUtilities.getSimulationTitles():
            simulationParametersRef = self.getSimulationParametersReference(
                title)

            filepathReference = os.path.abspath(
                os.path.join(self.testDataPath, "%s/%s.par" % (title, title)))

            filepath = os.path.join(self.tempDataPath, "%s.par" % (title))
            simulationParameters = SimulationParameters.SimulationParameters()
            simulationParameters = simulationParametersRef

            simulationParameters.write(filepath)

            self.assertEquals(simulationParametersRef.baseFilename,
                              simulationParameters.baseFilename)
            self.assertEquals(simulationParametersRef.numberElectrons,
                              simulationParameters.numberElectrons)
            self.assertEquals(simulationParametersRef.numberPhotons,
                              simulationParameters.numberPhotons)
            self.assertEquals(simulationParametersRef.numberWindows,
                              simulationParameters.numberWindows)
            self.assertEquals(simulationParametersRef.numberFilmsX,
                              simulationParameters.numberFilmsX)
            self.assertEquals(simulationParametersRef.numberFilmsY,
                              simulationParameters.numberFilmsY)
            self.assertEquals(simulationParametersRef.numberFilmsZ,
                              simulationParameters.numberFilmsZ)
            self.assertEquals(simulationParametersRef.numberChannels,
                              simulationParameters.numberChannels)
            self.assertEquals(simulationParametersRef.energyChannelWidth_eV,
                              simulationParameters.energyChannelWidth_eV)
            self.assertEquals(
                simulationParametersRef.spectrumInterpolationModel,
                simulationParameters.spectrumInterpolationModel)
            self.assertEquals(simulationParametersRef.voxelSimplification,
                              simulationParameters.voxelSimplification, title)

            linesRef = open(filepathReference, 'r').readlines()
            lines = open(filepath, 'r').readlines()

            self.assertListEqual(linesRef, lines)
    def test_read(self):
        """
        Tests for method `read`.
        """
        raise SkipTest

        for title in testUtilities.getSimulationTitles():
            resultsParameters = ResultsParameters.ResultsParameters()

            filepath = os.path.abspath(os.path.join(self.testDataPath, "%s/%s.rp" % (title, title)))
            resultsParameters.read(filepath)

            resultsParametersRef = self.getSimulationParametersReference(title)
            self.assertEquals(resultsParametersRef.isComputeXrayCharacteristic, resultsParameters.isComputeXrayCharacteristic)
            self.assertEquals(resultsParametersRef.isComputeXrayBremsstrahlung, resultsParameters.isComputeXrayBremsstrahlung)
            self.assertEquals(resultsParametersRef.isComputeXrayPhirhoz, resultsParameters.isComputeXrayPhirhoz)

        self.fail("Test if the testcase is working.")
Example #8
0
    def test_read(self):
        """
        Tests for method `read`.
        """

        simulationInputs = SimulationInputs.SimulationInputs()

        for title in testUtilities.getSimulationTitles():
            filepath = os.path.abspath(
                os.path.join(self.testDataPath, "%s/%s.sim" % (title, title)))
            simulationInputs.read(filepath)

            self.assertEquals(title, simulationInputs.title)

            self.assertEquals("%s.sam" % (title),
                              simulationInputs.specimenFilename)
            self.assertEquals("%s.mdl" % (title),
                              simulationInputs.modelFilename)
            self.assertEquals("%s.mic" % (title),
                              simulationInputs.microsopeFilename)
            self.assertEquals("%s.par" % (title),
                              simulationInputs.simulationParametersFilename)
    def test_read(self):
        """
        Tests for method `read`.
        """

        for title in testUtilities.getSimulationTitles():
            simulationParameters = SimulationParameters.SimulationParameters()

            filepath = os.path.abspath(
                os.path.join(self.testDataPath, "%s/%s.par" % (title, title)))
            simulationParameters.read(filepath)

            simulationParametersRef = self.getSimulationParametersReference(
                title)
            self.assertEquals(simulationParametersRef.baseFilename,
                              simulationParameters.baseFilename)
            self.assertEquals(simulationParametersRef.numberElectrons,
                              simulationParameters.numberElectrons)
            self.assertEquals(simulationParametersRef.numberPhotons,
                              simulationParameters.numberPhotons)
            self.assertEquals(simulationParametersRef.numberWindows,
                              simulationParameters.numberWindows)
            self.assertEquals(simulationParametersRef.numberFilmsX,
                              simulationParameters.numberFilmsX)
            self.assertEquals(simulationParametersRef.numberFilmsY,
                              simulationParameters.numberFilmsY)
            self.assertEquals(simulationParametersRef.numberFilmsZ,
                              simulationParameters.numberFilmsZ)
            self.assertEquals(simulationParametersRef.numberChannels,
                              simulationParameters.numberChannels)
            self.assertEquals(simulationParametersRef.energyChannelWidth_eV,
                              simulationParameters.energyChannelWidth_eV)
            self.assertEquals(
                simulationParametersRef.spectrumInterpolationModel,
                simulationParameters.spectrumInterpolationModel)
            self.assertEquals(simulationParametersRef.voxelSimplification,
                              simulationParameters.voxelSimplification, title)
Example #10
0
    def test_write(self):
        """
        Tests for method `write`.
        """
        raise SkipTest

        self.maxDiff = None

        for title in testUtilities.getSimulationTitles():
            filepathReference = os.path.abspath(
                os.path.join(self.testDataPath, "%s/%s.mdl" % (title, title)))

            filepath = os.path.join(self.tempDataPath, "%s.mdl" % (title))
            models = Models.Models()
            models._modelList[
                Models.KEY_XRAY_CS_BREMSSTRAHLUNG_MODEL].setModel(
                    MCXRayModel.XRayCSBremsstrahlungModel.TYPE_DING)

            models.write(filepath)

            linesRef = open(filepathReference, 'r').readlines()
            lines = open(filepath, 'r').readlines()

            self.assertListEqual(linesRef, lines)