Ejemplo n.º 1
0
    def test_mci_wrapper_book_example_2(self):
        """see if our result matches the one from
        Biomedical Optics
        Principles and Imaging
        page 56 (Table 3.2)"""
        # create a book_p56_mci which shall create a mci file
        book_p56_mci = MciWrapper()
        book_p56_mci.set_mci_filename(self.mci_filename)
        book_p56_mci.set_mco_filename(self.mco_filename)
        book_p56_mci.set_nr_photons(10**6)
        book_p56_mci.add_layer(1.5, 1000, 9000, 0., 1)

        mcml_path, mcml_file = os.path.split(path_to_gpumcml)
        if os.path.isfile(path_to_gpumcml):
            book_p56_mci.create_mci_file()
            sim_wrapper = SimWrapper()
            sim_wrapper.set_mci_filename(self.mci_filename)
            sim_wrapper.set_mcml_executable(path_to_gpumcml)
            sim_wrapper.run_simulation()
            self.assertTrue(os.path.isfile(mcml_path + "/" + self.mco_filename),
                        "mco file was created")
            refl = get_total_reflectance(os.path.join(mcml_path,
                                                      self.mco_filename))
            self.assertAlmostEqual(refl, 0.26, delta=0.01,
                                   msg="correct reflectance determined " +
                                   "according to book table 3.2")
Ejemplo n.º 2
0
    def __init__(self, ns, uas, usgs, ds):
        self._mci_wrapper = MciWrapper()

        self.wavelength = 500. * 10**9  # standard wavelength, should be set.
        self.uas = uas
        self.usgs = usgs
        self.ds = ds
        self.ns = ns
        # initially create layers. these will be overwritten as soon
        # as create_mci_file is called.
        for i in enumerate(uas):
            self._mci_wrapper.add_layer()
Ejemplo n.º 3
0
 def setUp(self):
     self.mci_filename = "temp.mci"
     self.mco_filename = "temp.mco"
     # create a mci_wrapper which shall create a mci file
     self.mci_wrapper = MciWrapper()
     self.mci_wrapper.set_mci_filename(self.mci_filename)
     self.mci_wrapper.set_mco_filename(self.mco_filename)
     self.mci_wrapper.set_nr_photons(10 ** 6)
     self.mci_wrapper.add_layer(1.0, 2.1, 3.2, 4.3, 5.4)
     self.mci_wrapper.add_layer(6.5, 7.8, 8.9, 9.10, 10.11)
     self.mci_wrapper.add_layer(100.1001, 101.10001, 102.100001,
                            103.1000001, 104.10000001)
     self.mci_wrapper.set_layer(1, 1, 1, 1, 1, 1)
     # expected mci file
     self.correct_mci_filename = "./mc/data/correct.mci"