예제 #1
0
 def test_field(self, bohren=False, cartesian=False):
     p = self.method.particle
     p.a_p = 1.
     p.n_p = 1.4
     p.r_p = [64, 64, 100]
     c = coordinates([128, 128])
     self.method.coordinates = c
     field = self.method.field(bohren=bohren, cartesian=cartesian)
     self.assertEqual(field.shape[1], c.shape[1])
예제 #2
0
 def test_hologram(self):
     p = self.method.particle
     p.a_p = 1.
     p.n_p = 1.4
     p.r_p = [64, 64, 100]
     c = coordinates([128, 128])
     self.method.coordinates = c
     hologram = self.method.hologram()
     self.assertEqual(hologram.shape[0], c.shape[1])
예제 #3
0
 def setUp(self):
     data = cv2.imread(TEST_IMAGE, 0).astype(float)
     data /= np.mean(data)
     coords = coordinates(data.shape)
     model = LMHologram(wavelength=0.447, magnification=0.048, n_m=1.34)
     self.data = data
     self.coords = coords
     self.feature = Feature(data=data,
                            coordinates=coords,
                            model=model,
                            percentpix=0.1)
     model.particle.r_p = [data.shape[0] // 2, data.shape[1] // 2, 330]
     model.particle.a_p = 1.1
     model.particle.n_p = 1.4
예제 #4
0
 def setUp(self):
     img = cv2.imread(TEST_IMAGE, 0).astype(float)
     img /= np.mean(img)
     img = img[::4, ::4]
     self.shape = img.shape
     self.data = img.ravel()
     self.coordinates = 4. * coordinates(self.shape)
     model = LMHologram(coordinates=self.coordinates)
     model.instrument.wavelength = 0.447
     model.instrument.magnification = 0.048
     model.instrument.n_m = 1.34
     model.particle.r_p = [self.shape[0] // 2, self.shape[1] // 2, 330]
     model.particle.a_p = 1.1
     model.particle.n_p = 1.4
     self.optimizer = Optimizer(model=model)
예제 #5
0
    def test_compare_methods(self):
        '''check that numpy and cupy pipelines yield consistent results'''
        shape = [128, 128]
        c = coordinates(shape)
        self.method.coordinates = c
        self.nmethod.coordinates = c

        p = self.method.particle
        p.a_p = 1.
        p.n_p = 1.4
        p.r_p = [64, 64, 100]
        self.nmethod.particle = p

        field = self.method.field()
        nfield = self.nmethod.field()
        inten = np.sum(np.abs(field), axis=0).reshape(shape)
        ninten = np.sum(np.abs(nfield), axis=0).reshape(shape)

        self.assertTrue(np.allclose(inten, ninten))
예제 #6
0
 def test_coordinates(self, corner=None):
     shape = [128, 128]
     c = coordinates(shape, corner=corner)
     self.assertEqual(c.shape[1], np.prod(shape))
예제 #7
0
 def test_normal(self):
     c = coordinates(self.shape, flatten=False)
     self.assertEqual(c.ndim, 3)
예제 #8
0
 def test_flatten(self):
     c = coordinates(self.shape)
     self.assertEqual(c.ndim, 2)
예제 #9
0
 def setUp(self):
     self.shape = [128, 128]
     self.coordinates = coordinates(self.shape)
     self.mask = Mask(self.coordinates)
예제 #10
0
 def test_coordinates(self):
     c = coordinates(self.shape)
     self.method.coordinates = c
     self.assertEqual(self.method.coordinates.shape[1], c.shape[1])
예제 #11
0
 def test_coordinates_2d(self):
     c = coordinates(self.shape)
     self.method.coordinates = c
     self.assertEqual(self.method.coordinates.shape[0], 3)
     self.assertTrue(np.allclose(self.method.coordinates[0:2, :], c))