Exemplo n.º 1
0
    def _testAdjointMany(self, backend, dtype, ntransforms=2):
        if not backend_available(backend):
            raise SkipTest

        complex_dtype = complex_type(dtype)

        plan = Plan(
            self.plane.shape,
            self.fourier_pts[:2].astype(dtype),
            backend=backend,
            ntransforms=ntransforms,
        )

        batch = np.empty(
            (ntransforms, *self.recip_space_plane.shape), dtype=complex_dtype
        )
        for i in range(ntransforms):
            batch[i] = self.recip_space_plane

        # Test Adjoint
        result = plan.adjoint(batch)

        for r in range(ntransforms):
            self.assertTrue(
                np.allclose(result[r], self.adjoint_plane, atol=utest_tolerance(dtype))
            )
Exemplo n.º 2
0
 def testSimulationImagesNoisy(self):
     images = self.sim.images(0, 512).asnumpy()
     self.assertTrue(
         np.allclose(
             images,
             np.load(os.path.join(DATA_DIR, "sim_images_with_noise.npy")),
             rtol=1e-2,
             atol=utest_tolerance(self.sim.dtype),
         ))
 def testAnisotropicNoiseVariance(self):
     noise_estimator = AnisotropicNoiseEstimator(self.sim, batchSize=512)
     noise_variance = noise_estimator.estimate()
     self.assertTrue(
         np.allclose(
             0.04534846544265747,
             noise_variance,
             atol=utest_tolerance(self.sim.dtype),
         ))
Exemplo n.º 4
0
 def testSimulationImagesDownsample(self):
     # The simulation already generates images of size 8 x 8; Downsampling to resolution 8 should thus have no effect
     self.sim.downsample(8)
     images = self.sim.clean_images(0, 512).asnumpy()
     self.assertTrue(
         np.allclose(
             images,
             np.load(os.path.join(DATA_DIR, "sim_clean_images.npy")),
             rtol=1e-2,
             atol=utest_tolerance(self.sim.dtype),
         ))
Exemplo n.º 5
0
    def _testAdjoint(self, backend, dtype):
        if not backend_available(backend):
            raise SkipTest

        complex_dtype = complex_type(dtype)

        plan = Plan(self.vol.shape, self.fourier_pts.astype(dtype), backend=backend)

        # Test Adjoint
        result = plan.adjoint(self.recip_space.astype(complex_dtype))

        self.assertTrue(
            np.allclose(result, self.adjoint_vol, atol=utest_tolerance(dtype))
        )