コード例 #1
0
def test_multiscale_gaussian(map_test):

    # Assuming the algorithm works fine then the below two should be equal.
    expect1 = enhance.mgn(map_test, [1])
    expect2 = enhance.mgn(map_test, [1, 1])

    assert np.allclose(expect1, expect2)

    result1 = np.zeros((4, 4), dtype=float)
    expect3 = enhance.mgn(map_test, [1])

    assert np.allclose(result1, expect3)

    # This is a dummy test. These values were not verified by hand rather they were
    # generated using the code itself.
    result2 = np.array([
        [0.0305363, 0.0305363, 0.0305363, 0.0305363],
        [0.0305363, 0.0305363, 0.0305363, 0.0305363],
        [0.0305363, 0.0305363, 0.0305363, 0.0305363],
        [0.0305363, 0.0305363, 0.0305363, 0.0305363],
    ])

    expect4 = enhance.mgn(map_test)

    assert np.allclose(result2, expect4)
コード例 #2
0
import sunkit_image.enhance as enhance

###########################################################################
# SunPy sample data contains a number of suitable images, which we will use here.
aia_map = sunpy.map.Map(sunpy.data.sample.AIA_171_IMAGE)

# The original image is plotted to showcase the difference.
fig = plt.figure()
ax = plt.subplot(projection=aia_map)
aia_map.plot()

###########################################################################
# Applying Multi-scale Gaussian Normalization on a solar image.
# The `sunkit_image.enhance.mgn` function takes a `numpy.ndarray` as a input so we will pass only
# the data part of `~sunpy.map.GenericMap`
out = enhance.mgn(aia_map.data)

# The value returned is also a numpy.ndarray so we convert it back to
# a  sunpy.map.GenericMap.
out = sunpy.map.Map(out, aia_map.meta)

###########################################################################
# The resulting map is plotted.
fig = plt.figure()
ax = plt.subplot(projection=out)
out.plot()

# All the plots are plotted at the end
plt.show()
コード例 #3
0
def test_mgn(smap):

    out = enhance.mgn(smap.data)
    out = sunpy.map.Map(out, smap.meta)

    out.plot()
コード例 #4
0
ファイル: test_enhance.py プロジェクト: hayesla/sunkit-image
def test_nans_raise_warning(map_test):
    map_test[0, 0] = np.nan
    with pytest.warns(UserWarning,
                      match="One or more entries in the input data are NaN."):
        _ = enhance.mgn(map_test)