Finding and masking bright pixels#

How to find and overplot the location of the brightest pixel and then mask pixels around that region.

import matplotlib.pyplot as plt
import numpy as np
import as ma

import astropy.units as u

from import AIA_171_IMAGE
from import all_coordinates_from_map

We start with the sample data.

aia =

To find the brightest pixel, we find the maximum in the AIA image data then transform that pixel coordinate to a map coordinate.

Let’s plot the results.

fig = plt.figure()
ax = fig.add_subplot(projection=aia)
ax.plot_coord(hpc_max, color='white', marker='x', markersize=15)
AIA $171 \; \mathrm{\mathring{A}}$ 2011-06-07 06:33:02

A utility function gives us access to the helioprojective coordinate of each pixels. We create a new array which contains the normalized radial position for each pixel adjusted for the position of the brightest pixel (using hpc_max) and then create a new map.

hpc_coords = all_coordinates_from_map(aia)
r_mask = np.sqrt((hpc_coords.Tx - hpc_max.Tx) ** 2 +
                 (hpc_coords.Ty - hpc_max.Ty) ** 2) / aia.rsun_obs
mask = ma.masked_less_equal(r_mask, 0.1)
scaled_map =, aia.meta, mask=mask.mask)

Let’s plot the results.

fig = plt.figure()
ax = fig.add_subplot(projection=scaled_map)
AIA $171 \; \mathrm{\mathring{A}}$ 2011-06-07 06:33:02

Total running time of the script: (0 minutes 0.665 seconds)

Gallery generated by Sphinx-Gallery