SunPy: A Python package for Solar Physics

Stuart J. Mumford∗1, 2, 3, Nabil Freij4, Steven Christe5, Jack Ireland5, Florian Mayer6, V. Keith Hughitt7, Albert Y. Shih5, Daniel F. Ryan8, 5, Simon Liedtke6, David Pérez-Suárez9, Pritish Chakraborty10, Vishnunarayan K I.6, Andrew Inglis11, Punyaslok Pattnaik12, Brigitta Sipőcz13, Rishabh Sharma6, Andrew Leonard3, David Stansby14, Russell Hewett15, Alex Hamilton6, Laura Hayes5, Asish Panda6, Matt Earnshaw6, Nitin Choudhary16, Ankit Kumar6, Prateek Chanda17, Md Akramul Haque18, Michael S Kirk11, Michael Mueller6, Sudarshan Konge6, Rajul Srivastava6, Yash Jain19, Samuel Bennett6, Ankit Baruah6, Will Barnes20, Michael Charlton6, Shane Maloney21, Nicky Chorley22, Himanshu6, Sanskar Modi6, James Paul Mason6, Naman96396, Jose Ivan Campos Rozo23, Larry Manley6, Agneet Chatterjee24, John Evans6, Michael Malocha6, Monica G. Bobra25, Sourav Ghosh24, Airmansmith976, Dominik Stańczak26, Ruben De Visscher6, Shresth Verma27, Ankit Agrawal6, Dumindu Buddhika6, Swapnil Sharma6, Jongyeob Park28, Matt Bates6, Dhruv Goel6, Garrison Taylor29, Goran Cetusic6, Jacob6, Mateo Inchaurrandieta6, Sally Dacie30, Sanjeev Dubey6, Deepankar Sharma6, Erik M. Bray6, Jai Ram Rideout31, Serge Zahniy5, Tomas Meszaros6, Abhigyan Bose6, André Chicrala32, Ankit6, Chloé Guennou6, Daniel D’Avella6, Daniel Williams33, Jordan Ballew6, Nick Murphy34, Priyank Lodha6, Thomas Robitaille6, Yash Krishan6, Andrew Hill6, Arthur Eigenbrot35, Benjamin Mampaey36, Bernhard M. Wiedemann6, Carlos Molina6, Duygu Keşkek6, Ishtyaq Habib6, Joseph Letts6, Juanjo Bazán37, Quinn Arbolante38, Reid Gomillion6, Yash Kothari6, Yash Sharma6, Abigail L. Stevens39, 40, Adrian Price-Whelan41, Ambar Mehrotra6, Arseniy Kustov6, Brandon Stone6, Trung Kien Dang42, Emmanuel Arias6, Fionnlagh Mackenzie Dover1, Freek Verstringe36, Gulshan Kumar43, Harsh Mathur44, Igor Babuschkin6, Jaylen Wimbish6, Juan Camilo Buitrago-Casas6, Kalpesh Krishna45, Kaustubh Hiware46, Manas Mangaonkar6, Matthew Mendero6, Mickaël Schoentgen6, Norbert G Gyenge47, Ole Streicher48, Rajasekhar Reddy Mekala6, Rishabh Mishra6, Shashank Srikanth43, Sarthak Jain6, Tannmay Yadav49, Tessa D. Wilkinson6, Tiago M. D. Pereira50, 51, Yudhik Agrawal12, jamescalixto6, yasintoda6, and Sophie A. Murray52


In partnership with
This article and software are linked with research article DOI 10.3847/1538-4357/ab4f7a, published in the The Astrophysical Journal.

Summary
The Sun, our nearest star, is a local laboratory for studying universal physical processes. Solar physics as a discipline includes studying the Sun both as a star and as the primary driver of space weather throughout the heliosphere. Due to the Sun's proximity, the temporal and spatial resolution of solar observations are orders of magnitude larger than those of other stars. This leads to significant differences in the data-analysis software needs of solar physicists compared with astrophysicists.
The sunpy Python package is a community-developed, free, and open-source solar data analysis environment for Python. It is managed by the SunPy Project, an organization that facilitates and promotes the use of open development and open source packages like sunpy through community engagement and tools such as GitHub, mailing lists, and matrix.
The four most significant subpackages of sunpy are described below.
The sunpy.net subpackage provides a unified interface that simplifies and homogenizes search and retrieval by querying and downloading data from many solar data sources, irrespective of the underlying data-source client. It currently supports sourcing data from 18 different spaceand ground-based solar observatories.
The sunpy.map and sunpy.timeseries subpackages provide core data types (Map and Time Series, respectively) that are designed to provide a general, standard, and consistent interface * The author list in this paper is sorted by number of commits to the core SunPy repository.
for loading and representing solar data across different instruments and missions. These classes load data which conform to solar physics standards and conventions such as FITS (Wells, Greisen, & Harten, 1981), FITS World Coordinate Systems (WCS) (Greisen & Calabretta, 2002), and solar-specific FITS headers (Thompson, 2006), while allowing customization to account for differences in specific instruments. Visualization methods are also provided to inspect and plot those data. Example visulizations of both TimeSeries and Map are shown in Figure 1. The sunpy.coordinates subpackage provides support for representing and transforming coordinates used in solar physics and astrophysics. These coordinates may represent events (e.g., flares), features on or above the Sun (e.g., magnetic loops), or the position of structures traveling throughout the heliosphere (e.g., coronal mass ejections). The package currently implements the most widely used Sun-centered coordinate frames, and extends astropy.co ordinates.
Other functionality provided by sunpy includes physical models of solar behavior, such as differential rotation, color maps for certain data sources, image-processing routines integrated with Map, and useful physical parameters such as constants.
The sunpy package is designed to be extensible, which means that it is easy to add support for additional instruments or data sources. It relies heavily on the astropy (The Astropy Collaboration et al., 2018) Python package as well as the scientific python stack (e.g. numpy (van der Walt, Colbert, & Varoquaux, 2011), scipy (Jones, Oliphant, Peterson, & others, n.d.), matplotlib (Hunter, 2007) and pandas (McKinney, 2010)).
A more complete description of the SunPy Project and the sunpy package, including the methodology, development model, and implementation, as well as a comparison with other commonly-used packages in solar physics, can be found in (Barnes et al., 2020).
The SunPy Project supports affiliated packages, which build upon or extend the functionality of sunpy. The current affiliated packages are drms (Glogowski, Bobra, Choudhary, Amezcua, & Mumford, 2019), ndcube, radiospectra and IRISPy. The Project is also a member of the Python in Heliophysics community (PyHC, Annex et al., 2018), whose mission is to enable interdisciplinary analysis across all sub-disciplines of heliophysics by adhering to standards for code development and interoperability.