Exemplo n.º 1
0
 def test_compute_intensity(self):
     shape = (32, 32)
     u = (np.ones(shape) + 1j * np.ones(shape) * 3).astype(
         cfg.PRECISION.np_cplx)
     np.testing.assert_almost_equal(
         np.abs(u)**2,
         ip.compute_intensity(u).get())
Exemplo n.º 2
0
 def compare_sampling(gauss, factor):
     shape = (int(factor * self.n), ) * 2
     im = ip.compute_intensity(
         source.transfer(shape,
                         self.ps / factor,
                         self.energies[0],
                         check=False)).get()
     self.assertAlmostEqual(im.sum(), gauss.sum(), places=3)
     hd = ip.rescale(gauss, shape).get() / factor**2
     np.testing.assert_almost_equal(im, hd, decimal=5)
Exemplo n.º 3
0
def run_fixed():
    syris.init()
    n = 512
    ps = 1 * q.um
    energies = np.arange(5, 30) * q.keV
    y, x = np.mgrid[-n // 2:n // 2, -n // 2:n // 2]
    flux = np.exp(-(x**2 + y**2) / (100**2)) / q.s
    weights = np.arange(1, len(energies) + 1)[:, np.newaxis, np.newaxis]
    flux = weights * flux
    traj = Trajectory([(n / 2, n / 2, 0)] * ps)
    source = FixedSpectrumSource(energies,
                                 flux,
                                 30 * q.m, (100, 500) * q.um,
                                 traj,
                                 pixel_size=ps)

    im = ip.compute_intensity(source.transfer((n, n), ps, 5 * q.keV)).get()
    show(im, title="Original sampling")
    im = ip.compute_intensity(source.transfer((2 * n, ) * 2, ps / 2,
                                              5 * q.keV)).get()
    show(im, title="2x supersampled")
    plt.show()
Exemplo n.º 4
0
 def test_compute_intensity(self):
     shape = (32, 32)
     u = (np.ones(shape) + 1j * np.ones(shape) * 3).astype(cfg.PRECISION.np_cplx)
     np.testing.assert_almost_equal(np.abs(u) ** 2, ip.compute_intensity(u).get())