Ejemplo n.º 1
0
def test_hansenlaw_shape():
    n = 21
    x = np.ones((n, n), dtype='float32')

    recon = iabel_hansenlaw(x, verbose=False)

    assert recon.shape == (n, n)
Ejemplo n.º 2
0
def test_hansenlaw_zeros():
    n = 21
    x = np.zeros((n, n), dtype='float32')

    recon = iabel_hansenlaw(x, verbose=False)

    assert_allclose(recon, 0)
Ejemplo n.º 3
0
def test_hansenlaw_zeros():
    n = 21
    x = np.zeros((n, n), dtype='float32')

    recon = iabel_hansenlaw(x, verbose=False)

    assert_allclose(recon, 0)
Ejemplo n.º 4
0
def test_hansenlaw_shape():
    n = 21
    x = np.ones((n, n), dtype='float32')

    recon = iabel_hansenlaw(x, verbose=False)

    assert recon.shape == (n, n) 
Ejemplo n.º 5
0
def test_hansenlaw_zeros():
    n = 21
    x = np.zeros((n, n), dtype="float32")

    recon = iabel_hansenlaw(x, calc_speeds=False, verbose=False)

    assert_allclose(recon, 0)
Ejemplo n.º 6
0
def test_hansenlaw_shape():
    n = 21
    x = np.ones((n, n), dtype="float32")

    recon = iabel_hansenlaw(x, calc_speeds=False, verbose=False)

    assert recon.shape == (n, n)
Ejemplo n.º 7
0
def test_iabel_hansenlaw_gaussian():
    """Check iabel_hansenlaw with a Gaussian function"""
    n = 1001  # better with a larger number of points
    r_max = 501

    ref = GaussianAnalytical(n, r_max, symmetric=True, sigma=200)
    tr = np.tile(ref.abel[None, :], (n, 1))  # make a 2D array from 1D

    recon = iabel_hansenlaw(tr, ref.dr)
    recon1d = recon[n // 2 + n % 2]  # centre row

    ratio = absolute_ratio_benchmark(ref, recon1d)

    assert_allclose(ratio, 1.0, rtol=1e-1, atol=0)
Ejemplo n.º 8
0
def test_iabel_hansenlaw_gaussian():
    """Check iabel_hansenlaw with a Gaussian function"""
    n = 1001   # better with a larger number of points
    r_max = 501

    ref = GaussianAnalytical(n, r_max, symmetric=True,  sigma=200)
    tr = np.tile(ref.abel[None, :], (n, 1)) # make a 2D array from 1D

    recon = iabel_hansenlaw(tr, ref.dr)
    recon1d = recon[n//2 + n%2]  # centre row

    ratio = absolute_ratio_benchmark(ref, recon1d)

    assert_allclose(ratio, 1.0, rtol=1e-1, atol=0)
Ejemplo n.º 9
0
def test_hansenlaw_gaussian():
    """Check a gaussian solution for HansenLaw"""
    n = 51
    r_max = 25

    ref = GaussianAnalytical(n, r_max, symmetric=True, sigma=10)
    tr = np.tile(ref.abel[None, :], (n, 1))  # make a 2D array from 1D

    recon = iabel_hansenlaw(tr, calc_speeds=False, verbose=False)
    recon1d = recon[n // 2 + n % 2]

    ratio = absolute_ratio_benchmark(ref, recon1d)

    # this only passes with a relative tolerance of 0.35, someone would
    # need to look into it.
    assert_allclose(ratio, 1.0, rtol=0.35, atol=0)
Ejemplo n.º 10
0
if cols % 2 == 0:
    print("HL: even pixel width image, re-adjust image centre")
    # re-center image based on horizontal and vertical slice profiles
    # covering the radial range [300:400] pixels from the center
    IM = find_image_center_by_slice(IM, radial_range=(300, 400))[0]
    rows, cols = IM.shape  # new image size

c2 = cols // 2  # half-image
print('image size {:d}x{:d}'.format(rows, cols))

# Step 2: perform the Hansen & Law transform!
print('Performing Hansen and Law inverse Abel transform:')

AIM = iabel_hansenlaw(IM,
                      dr=1,
                      use_quadrants=(True, True, True, True),
                      vertical_symmetry=False,
                      horizontal_symmetry=False,
                      verbose=True)

speeds, r = calculate_speeds(AIM)

# Set up some axes
fig = plt.figure(figsize=(15, 4))
ax1 = plt.subplot(131)
ax2 = plt.subplot(132)
ax3 = plt.subplot(133)

# Plot the raw data
im1 = ax1.imshow(IM, origin='lower', aspect='auto')
fig.colorbar(im1, ax=ax1, fraction=.1, shrink=0.9, pad=0.03)
ax1.set_xlabel('x (pixels)')
Ejemplo n.º 11
0
# Image center should be mid-pixel, i.e. odd number of colums
if cols%2 == 0: 
   print ("HL: even pixel width image, re-adjust image centre")
   # re-center image based on horizontal and vertical slice profiles
   # covering the radial range [300:400] pixels from the center
   IM = find_image_center_by_slice (IM, radial_range=(300,400))[0]
   rows,cols = IM.shape   # new image size

c2 = cols//2   # half-image
print ('image size {:d}x{:d}'.format(rows,cols))

# Step 2: perform the Hansen & Law transform!
print('Performing Hansen and Law inverse Abel transform:')

AIM = iabel_hansenlaw(IM, dr=1, use_quadrants=(True,True,True,True),
                                vertical_symmetry=False,
                                horizontal_symmetry=False,
                                verbose=True)

speeds, r = calculate_speeds (AIM)

# Set up some axes
fig = plt.figure(figsize=(15,4))
ax1 = plt.subplot(131)
ax2 = plt.subplot(132)
ax3 = plt.subplot(133)

# Plot the raw data
im1 = ax1.imshow(IM,origin='lower',aspect='auto')
fig.colorbar(im1,ax=ax1,fraction=.1,shrink=0.9,pad=0.03)
ax1.set_xlabel('x (pixels)')
ax1.set_ylabel('y (pixels)')