Esempio n. 1
0
def test_all_pixel_indices_from_map(sub_smap):
    pixel_indices = all_pixel_indices_from_map(sub_smap)
    shape = sub_smap.data.shape
    ny = shape[0]
    nx = shape[1]
    assert np.all(pixel_indices.shape == (2, ny, nx))
    assert np.all(pixel_indices.unit == u.pix)
    assert np.all(pixel_indices[:, 0, 0] == [0., 0.] * u.pix)
    assert np.all(pixel_indices[:, 0, nx-1] == [nx-1, 0.] * u.pix)
    assert np.all(pixel_indices[:, ny-1, 0] == [0., ny-1] * u.pix)
    assert np.all(pixel_indices[:, ny-1, nx-1] == [nx-1, ny-1] * u.pix)
Esempio n. 2
0
def test_all_pixel_indices_from_map(sub_smap):
    pixel_indices = all_pixel_indices_from_map(sub_smap)
    shape = sub_smap.data.shape
    ny = shape[0]
    nx = shape[1]
    assert np.all(pixel_indices.shape == (2, ny, nx))
    assert np.all(pixel_indices.unit == u.pix)
    assert np.all(pixel_indices[:, 0, 0] == [0., 0.] * u.pix)
    assert np.all(pixel_indices[:, 0, nx - 1] == [nx - 1, 0.] * u.pix)
    assert np.all(pixel_indices[:, ny - 1, 0] == [0., ny - 1] * u.pix)
    assert np.all(pixel_indices[:, ny - 1, nx - 1] == [nx - 1, ny - 1] * u.pix)
from sunpy.data.sample import AIA_193_IMAGE
from sunpy.map.maputils import all_pixel_indices_from_map

###############################################################################
# We will first create a Map using some sample data and display it.

aiamap = sunpy.map.Map(AIA_193_IMAGE)
plt.figure()
aiamap.plot()
plt.colorbar()

###############################################################################
# Before we find regions of local maxima, we need to create some variables to
# store pixel values for the 2D SDO/AIA data we are using.
# These variables are used for plotting in 3D later on.
X, Y = all_pixel_indices_from_map(aiamap)

#######################################################################################
# We will only consider peaks within the AIA data that have minimum intensity
# value equal to ``threshold_rel * max(Intensity)`` which is 20% of the maximum intensity.
# The next step is to calculate the pixel locations of local maxima
# positions where peaks are separated by at least ``min_distance = 60 pixels``.
# This function comes from scikit image and the documenation is found
# here `~skimage.feature.peak_local_max`.

coordinates = peak_local_max(aiamap.data, min_distance=60, threshold_rel=0.2)

###############################################################################
# We now check for the indices at which we get such a local maxima and plot
# those positions marked red in the aiamap data.