SunPy
raw JSON → 7.1.2 verified Mon Apr 27 auth: no python
SunPy is the core package for solar data analysis in Python, providing data structures, coordinate transformations, and visualization tools for solar physics. Current version 7.1.2 (requires Python >=3.12). Released approximately every 3-4 months.
pip install sunpy[all] Common errors
error ImportError: cannot import name 'Map' from 'sunpy' ↓
cause Using 'from sunpy import Map' which imports the module, not the class.
fix
Use 'import sunpy.map' then 'sunpy.map.Map'.
error TypeError: Cannot parse unit from input ↓
cause Passing plain numbers to coordinate constructors without astropy units.
fix
Use astropy.units, e.g., coord = SkyCoord(10*u.deg, 20*u.deg, frame='heliographic_stonyhurst').
error sunpy.net.vso - VSOClient error: No data found for the given query ↓
cause VSO query parameters too restrictive or server issue; JSOC may have different availability.
fix
Broaden time range or use different instrument/wavelength. Consider using Fido with attrs from sunpy.net.attrs.
Warnings
breaking sunpy 7.x requires Python >=3.12; dropped support for Python 3.10 and 3.11. ↓
fix Upgrade to Python 3.12 or later.
deprecated sunpy.coordinates.frames.HeliographicStonyhurst no longer accepts 'deg' as input unit by default; must use Quantity with appropriate units. ↓
fix Use astropy.coordinates.SkyCoord with proper astropy.units, e.g., coord = SkyCoord(10*u.deg, 20*u.deg, frame='heliographic_stonyhurst').
gotcha Fido.fetch returns a list of paths, but some downloaders (e.g., JSOC) can return paths that are relative; always resolve to absolute path before using in Map. ↓
fix Use str(Path(files[0]).resolve()) or pass the path through sunpy.map.Map.
gotcha sunpy.map.Map() requires a FITS file or array; passing a URL directly will fail. ↓
fix Download the file first using Fido.fetch or another download method, then pass the local path.
Imports
- Map wrong
from sunpy import Mapcorrectimport sunpy.map - sunpy.map.Map wrong
from sunpy.map import Mapcorrectimport sunpy.map; smap = sunpy.map.Map(...)
Quickstart
import sunpy.map
import astropy.units as u
from sunpy.net import Fido, attrs as a
# Download an AIA 193 image (requires internet)
result = Fido.search(a.Time('2020-01-01 00:00:00', '2020-01-01 00:00:10'),
a.Instrument.aia, a.Wavelength(193*u.angstrom))
files = Fido.fetch(result)[0]
# Load and plot map
m = sunpy.map.Map(files)
m.plot()