def test_direct_zeros(): # just a sanity check if not cython_ext: raise SkipTest n = 64 x = np.zeros((n,n)) assert (fabel_direct(x)==0).all() assert (iabel_direct(x)==0).all()
def test_direct_zeros(): # just a sanity check if not cython_ext: raise SkipTest n = 64 x = np.zeros((n, n)) assert (fabel_direct(x) == 0).all() assert (iabel_direct(x) == 0).all()
def test_direct_shape(): if not cython_ext: raise SkipTest n = 21 x = np.ones((n, n)) recon = fabel_direct(x) assert recon.shape == (n, n) recon = iabel_direct(x) assert recon.shape == (n, n)
def test_inverse_direct_gaussian(): """Check iabel_direct with a Gaussian""" if not cython_ext: raise SkipTest n = 51 r_max = 25 ref = GaussianAnalytical(n, r_max, symmetric=False, sigma=10) recon = iabel_direct(ref.abel, dr=ref.dr) ratio = absolute_ratio_benchmark(ref, recon, kind='inverse') assert_allclose(ratio, 1.0, rtol=7e-2, atol=0)
sigma = 10 ref = GaussianAnalytical(n, r_max, sigma, symmetric=False) fig, ax = plt.subplots(1,2) ax[0].set_title('Forward transform of a Gaussian') ax[1].set_title('Inverse transform of a Gaussian') ax[0].plot(ref.r, ref.abel, 'b', label='Analytical transform') recon = fabel_direct(ref.func, dr=ref.dr, correction=True, backend='C') ax[0].plot(ref.r, recon , '--o',c='red', label='direct') recon = fabel_direct(ref.func, dr=ref.dr, correction=True, backend='Python') ax[0].plot(ref.r, recon , ':d', c='k', label='direct naive') ax[1].plot(ref.r, ref.func, 'b', label='Original function') recon = iabel_direct(ref.abel, dr=ref.dr, correction=True) ax[1].plot(ref.r, recon , '--o', c='red', label='direct') recon = iabel_direct(ref.abel, dr=ref.dr, correction=False) ax[1].plot(ref.r, recon , ':d', c='k', label='direct - naive') for axi in ax: axi.set_xlim(0, 20) axi.legend() plt.show()