How to create a sunpy Map#

One of the primary goals of the Map interface is to make it as easy as possible to create a Map. As such, you can pass many different kinds of inputs to Map. These are listed below.

File name#

If you have a FITS file, this is the easiest and recommended way to create a Map. This can be either a string or a Path.

>>> import pathlib

>>> import
>>> import

>>> my_map =  
>>> my_map ='file.fits')  
>>> my_map ='file.fits'))  
>>> sub_dir = pathlib.Path('local_dir/sub_dir')
>>> my_map = / 'another_file.fits')   

Directory containing FITS files#

If there is more than one FITS file in the directory, this will return a list of Map objects.

>>> my_maps ='local_dir/sub_dir')   
>>> my_maps =   

Array and

If needed, this way can be used to modify the header before passing it to Map.

>>> import

>>> with as hdul:
...     data = hdul[1].data
...     header = hdul[1].header  
>>> my_map =, header)  

These data header pairs can also be passed as a tuple,

>>> my_map =, header))  

Data array and a MetaDict object#

This includes any base class of MetaDict, including dict or collections.OrderedDict.

>>> import sunpy.util.metadata

>>> meta = sunpy.util.metadata.MetaDict(header)  
>>> my_map =, meta)   

Data array and an astropy.wcs.WCS object#

>>> import astropy.wcs

>>> wcs = astropy.wcs.WCS(header=header)  
>>> my_map =, wcs)  

Glob patterns#

If the glob pattern matches more than one FITS file, this will return a list of Map objects.

>>> my_map ='eit_*.fits')   


>>> sample_data_url = ''
>>> my_map =  

Combinations of any of the above#

These can either be in a list or as separate arguments. As with the case of a directory or glob pattern, this will return multiple Map objects.

>>> my_map =['file1.fits', 'file2.fits', 'file3.fits', 'directory1/'])  
>>> my_map =, header), data, meta, 'file1.fits', sample_data_url, 'eit_*.fits')