Generating a Map From Data

A simple demonstration of creating a map from a numpy array of data.

Start by importing the necessary modules.

from __future__ import print_function, division

import numpy as np
import matplotlib.pyplot as plt


SunPy Maps store 2D data in a numpy array and additional data in a metadata dictionary giving information relating to the data and instrument.

data = np.random.rand(20,15)
header = {}
manual_map =, header))

In general the attributes are populated using details in the metadata and in this case there is no centre pixel or pixel size information given so SunPy is defaulting to assuming each pixel is 1 arcsec.

# This is in Helioprojective tangent projection in both longitude and latitude:


[ 0.49791667  0.50208333] deg
[ 0.49722222  0.50277778] deg
SpatialPair(axis1='HPLN-   ', axis2='HPLT-   ')

You can quickly plot a map using the peek method:


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

Generated by Sphinx-Gallery