예제 #1
0
def test_radial_average_spectrum_distances():
    shape = (201, 201)
    area = (-100, 100, -100, 100)
    x, y = gridder.regular(area, shape)
    x, y = x.reshape(shape), y.reshape(shape)
    x, y = np.fft.ifftshift(x), np.fft.ifftshift(y)
    distances = np.sqrt(x**2 + y**2)
    k, radial_distances = transform.radial_average_spectrum(x, y, distances)
    npt.assert_allclose(k[2:], radial_distances[2:], rtol=0.1)  # doesn't fail
예제 #2
0
def test_radial_average_spectrum_distances():
    shape = (201, 201)
    area = (-100, 100, -100, 100)
    x, y = gridder.regular(area, shape)
    x, y = x.reshape(shape), y.reshape(shape)
    x, y = np.fft.ifftshift(x), np.fft.ifftshift(y)
    distances = np.sqrt(x**2 + y**2)
    k, radial_distances = transform.radial_average_spectrum(x, y, distances)
    npt.assert_allclose(k[2:], radial_distances[2:], rtol=0.1)  # doesn't fail
예제 #3
0
def test_radial_average_spectrum_integers():
    x = np.arange(-10, 11, 1)
    y = np.arange(-10, 11, 1)
    y, x = np.meshgrid(y, x)
    x, y = np.fft.ifftshift(x), np.fft.ifftshift(y)
    r = np.sqrt(x**2 + y**2)
    z = np.zeros(x.shape)
    integers = np.arange(0, x.max() + 1, 1)
    for i in integers:
        if i == 0:
            inside = r <= 0.5
        else:
            inside = np.logical_and(r > i - 0.5, r <= i + 0.5)
        z[inside] = i
    k, radial_z = transform.radial_average_spectrum(x, y, z)
    npt.assert_allclose(integers, radial_z, rtol=0.1)
예제 #4
0
def test_radial_average_spectrum_integers():
    x = np.arange(-10, 11, 1)
    y = np.arange(-10, 11, 1)
    y, x = np.meshgrid(y, x)
    x, y = np.fft.ifftshift(x), np.fft.ifftshift(y)
    r = np.sqrt(x**2 + y**2)
    z = np.zeros(x.shape)
    integers = np.arange(0, x.max() + 1, 1)
    for i in integers:
        if i == 0:
            inside = r <= 0.5
        else:
            inside = np.logical_and(r > i - 0.5, r <= i + 0.5)
        z[inside] = i
    k, radial_z = transform.radial_average_spectrum(x, y, z)
    npt.assert_allclose(integers, radial_z, rtol=0.1)
예제 #5
0
# Fetch Hawaii data
data = fetch_hawaii_gravity()

# When the data is projected using UTM zone 4, it is no longer regular gridded.
# We must regrid it.
area = (1.483e6, 3.079e6, -60e3, 1.326e6)
shape = (77, 67)
x, y, gravity = gridder.interp(data['x'], data['y'],
                               data['topo-free'],
                               shape, area=area)

# Lets compute the Power Density Spectra (2d arrays)
kx, ky, pds = transform.power_density_spectra(x, y, gravity, shape)

# And then compute the radial average of the PDS
k_radial, pds_radial = transform.radial_average_spectrum(kx, ky, pds)

# Plot Hawaii gravity and radially averaged power spectrum
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9, 4))
cm = ax1.contourf(y.reshape(shape),
                  x.reshape(shape),
                  gravity.reshape(shape), 100)
ax1.contour(y.reshape(shape),
            x.reshape(shape),
            gravity.reshape(shape),
            8, colors='k', linewidths=0.4)
ax1.set_aspect('equal')
ax1.set_xlabel('m')
ax1.set_ylabel('m')
ax1.ticklabel_format(axis='x', style='sci', scilimits=(1, 1))
ax1.ticklabel_format(axis='y', style='sci', scilimits=(1, 1))
예제 #6
0
# When the data is projected using UTM zone 4, it is no longer regular gridded.
# We must regrid it.
area = (1.483e6, 3.079e6, -60e3, 1.326e6)
shape = (77, 67)
x, y, gravity = gridder.interp(data['x'],
                               data['y'],
                               data['topo-free'],
                               shape,
                               area=area)

# Lets compute the Power Density Spectra (2d arrays)
kx, ky, pds = transform.power_density_spectra(x, y, gravity, shape)

# And then compute the radial average of the PDS
k_radial, pds_radial = transform.radial_average_spectrum(kx, ky, pds)

# Plot Hawaii gravity and radially averaged power spectrum
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(9, 4))
cm = ax1.contourf(y.reshape(shape), x.reshape(shape), gravity.reshape(shape),
                  100)
ax1.contour(y.reshape(shape),
            x.reshape(shape),
            gravity.reshape(shape),
            8,
            colors='k',
            linewidths=0.4)
ax1.set_aspect('equal')
ax1.set_xlabel('m')
ax1.set_ylabel('m')
ax1.ticklabel_format(axis='x', style='sci', scilimits=(1, 1))