def test_smooth_circular(): """Test smooth_circular 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_circular(hght, 2, 2) truth = [[5640., 5640., 5640., 5640., 5640.], [5684., 5676., 5666., 5659., 5651.], [5728., 5712., 5693.98817, 5678., 5662.], [5772., 5748., 5718., 5697., 5673.], [5816., 5784., 5744., 5716., 5684.]] * units.m assert_array_almost_equal(smoothed, truth, 4)
def test_smooth_circular(array_type): """Test smooth_circular 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_circular(hght, 2, 2) truth = array_type([[5640., 5640., 5640., 5640., 5640.], [5684., 5676., 5666., 5659., 5651.], [5728., 5712., 5693.98817, 5678., 5662.], [5772., 5748., 5718., 5697., 5673.], [5816., 5784., 5744., 5716., 5684.]], 'meter') assert_array_almost_equal(smoothed, truth, 4)
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) ax[2, 0].set_title('9-Point - 1 Pass') ax[2, 1].imshow(mpcalc.smooth_n_point(raw_data, 9, 4), vmin=0, vmax=1) ax[2, 1].set_title('9-Point - 4 Passes') # Arbitrary Window Smoother ax[2, 2].imshow(mpcalc.smooth_window(raw_data, np.diag(np.ones(5)), 2), vmin=0, vmax=1) ax[2, 2].set_title('Custom Window (Diagonal) \n2 Passes') plt.show()