Beispiel #1
0
def test_smooth_rectangular():
    """Test smooth_rectangular with default configuration."""
    hght = [[5640., 5640., 5640., 5640., 5640.],
            [5684., 5676., 5666., 5659., 5651.],
            [5728., 5712., 5692., 5678., 5662.],
            [5772., 5748., 5718., 5697., 5673.],
            [5816., 5784., 5744., 5716., 5684.]] * units.m
    smoothed = smooth_rectangular(hght, (5, 3))
    truth = [[5640., 5640., 5640., 5640., 5640.],
             [5684., 5676., 5666., 5659., 5651.],
             [5728., 5710.66667, 5694., 5677.33333, 5662.],
             [5772., 5748., 5718., 5697., 5673.],
             [5816., 5784., 5744., 5716., 5684.]] * units.m
    assert_array_almost_equal(smoothed, truth, 4)
Beispiel #2
0
def test_smooth_rectangular(array_type):
    """Test smooth_rectangular with default configuration."""
    hght = np.array([[5640., 5640., 5640., 5640., 5640.],
                     [5684., 5676., 5666., 5659., 5651.],
                     [5728., 5712., 5692., 5678., 5662.],
                     [5772., 5748., 5718., 5697., 5673.],
                     [5816., 5784., 5744., 5716., 5684.]])
    mask = np.zeros_like(hght)
    mask[::2, ::2] = 1
    hght = array_type(hght, 'meter', mask=mask)

    smoothed = smooth_rectangular(hght, (5, 3))
    truth = array_type([[5640., 5640., 5640., 5640., 5640.],
                        [5684., 5676., 5666., 5659., 5651.],
                        [5728., 5710.66667, 5694., 5677.33333, 5662.],
                        [5772., 5748., 5718., 5697., 5673.],
                        [5816., 5784., 5744., 5716., 5684.]], 'meter')
    assert_array_almost_equal(smoothed, truth, 4)
Beispiel #3
0
###########################################
# Now, create a grid showing different smoothing options
fig, ax = plt.subplots(3, 3, figsize=(12, 12))
for i, j in product(range(3), range(3)):
    ax[i, j].axis('off')

# Gaussian Smoother
ax[0, 0].imshow(mpcalc.smooth_gaussian(raw_data, 3), vmin=0, vmax=1)
ax[0, 0].set_title('Gaussian - Low Degree')

ax[0, 1].imshow(mpcalc.smooth_gaussian(raw_data, 8), vmin=0, vmax=1)
ax[0, 1].set_title('Gaussian - High Degree')

# Rectangular Smoother
ax[0, 2].imshow(mpcalc.smooth_rectangular(raw_data, (3, 7), 2), vmin=0, vmax=1)
ax[0, 2].set_title('Rectangular - 3x7 Window\n2 Passes')

# 5-point smoother
ax[1, 0].imshow(mpcalc.smooth_n_point(raw_data, 5, 1), vmin=0, vmax=1)
ax[1, 0].set_title('5-Point - 1 Pass')

ax[1, 1].imshow(mpcalc.smooth_n_point(raw_data, 5, 4), vmin=0, vmax=1)
ax[1, 1].set_title('5-Point - 4 Passes')

# Circular Smoother
ax[1, 2].imshow(mpcalc.smooth_circular(raw_data, 2, 2), vmin=0, vmax=1)
ax[1, 2].set_title('Circular - Radius 2\n2 Passes')

# 9-point smoother
ax[2, 0].imshow(mpcalc.smooth_n_point(raw_data, 9, 1), vmin=0, vmax=1)