Masking out the solar disk

How to mask out all emission from the solar disk.

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

from import AIA_171_IMAGE
from import all_coordinates_from_map

We start with the sample data

aia =

A utility function gives us access to the helioprojective coordinate of each pixels. We can use that to create a new array which contains the normalized radial position for each pixel.

hpc_coords = all_coordinates_from_map(aia)
r = np.sqrt(hpc_coords.Tx ** 2 + hpc_coords.Ty ** 2) / aia.rsun_obs

With this information, we create a mask where all values which are less then the solar radius are masked. We also make a slight change to the colormap so that masked values are shown as black instead of the default white.


/home/docs/checkouts/ MatplotlibDeprecationWarning: You are modifying the state of a globally registered colormap. In future versions, you will not be able to modify a registered colormap in-place. To remove this warning, you can make a copy of the colormap first. cmap = copy.copy("SDO AIA 171.0 Angstrom"))

Finally we create a new map with our new mask.

scaled_map =, aia.meta, mask=mask.mask)

Let’s plot the results using our modified colormap

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

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

Gallery generated by Sphinx-Gallery