Skip to content
Related Articles

Related Articles

SunPy | Plotting a Solar Image in Python

Improve Article
Save Article
  • Last Updated : 22 Oct, 2017
Improve Article
Save Article

SunPy is a package for solar data analysis using Python. We will be using this package for analysis of solar data

On the command line type:

 pip install sunpy

Downloading Sample Data

The SunPy package contains a number of data files which are solar data of proton/electron fluxes from various solar observatory and solar labs. They are stored under the module
To download the sample data simply run the following command:


In this small project, we will see a very simple way to plot a sample AIA image.
AIA = Atmospheric Imaging Assembly (AIA), is another instrument board the Solar Dynamics Observatory(SDO) designed to study the solar corona, taking simultaneous full disc images in multiple wavelengths of the corona and transitional region (up to half a solar radius above the solar limb), with 1.5 arc sec resolution and 12 second temporal cadence or better.
First we try to explore.
Maps: Maps are the primary data type in SunPy they are spatially and / or temporally aware data arrays. There are types of maps for a 2D image, a time series of 2D images or 1D spectra or 2D spectrograms. Making a map of your data is the normally the first step in using SunPy to work with your data.

Creating a Map

SunPy supports many different data products from various sources ‘out of the box’ we shall use SDO’s AIA instrument as an example in this tutorial. The general way to create a map from one of the supported data products is with the sunpy.Map() command.

sunpy.Map() takes either a filename, list of filenames data array and header. We can test map with:

import sunpy
aia = sunpy.Map(sunpy.AIA_171_IMAGE)

This returns a map named aia.

Plotting a sample solar data file

Let’s begin by creating a simple plot of an AIA image. To make things easy, SunPy includes several example files. These files have names like sunpy.AIA_171_IMAGE and sunpy.RHESSI_IMAGE.

from import AIA_171_IMAGE
# We now create the Map using the sample data.
aiamap =
# Now we do a quick plot.


If everything has been configured properly you should see an AIA image with a red colormap, a colorbar on the right-hand side and a title and some labels.
Solar data plotting is a crucial aspect in order to detect future solar flares and solar storms. Also it is important to note the variation of the proton and electron flux at various intervals of time.

This article is contributed by Prateek Chanda. If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!