SunPy: A Python package for Solar Physics

Stuart Mumford, Nabil Freij, Steven Christe, Jack Ireland, Florian Mayer, V. Keith Hughitt, Albert J. Shih, Daniel Ryan, Simon Liedtke, David Pérez-Suárez, Pritish Chakraborty, Vishnunarayan K, Andrew Inglis, Punyaslok Pattnaik, Brigitta M. Sipocz, Rishabh Sharma, Andrew Leonard, David Stansby, Russell J. Hewett, Alex Hamilton, Laura Hayes, Asish Panda, Matt Earnshaw, Nitin Choudhary, Ankit Kumar, Prateek Chanda, Md. Akramul Haque, Michael Kirk, Michael Mueller, Sudarshan Konge, Rajul Srivastava, Yash Jain, Samuel Bennett, Ankit Baruah, Will T. Barnes, Michael Charlton, Shane A. Maloney, Nicky Chorley, Himanshu, Sanskar Modi, James Mason, Jose Rozo, Larry Manley, Agneet Chatterjee, John Evans, Michael Malocha, Monica G. Bobra, Sourav Ghosh, Dominik Stanczak, Ruben De Visscher, Shresth Verma, Ankit Agrawal 0011, Dumindu Buddhika, Swapnil Sharma, Jongyeob Park, Matt Bates, Dhruv Goel, Garrison Taylor, Goran Cetusic, Jacob, Mateo Inchaurrandieta, Sally Dacie, Sanjeev Dubey, Deepankar Sharma, Erik Bray, Jai Rideout, Serge Zahniy, Tomas Meszaros, Abhigyan Bose, André Chicrala, Ankit, Chloé Guennou, Daniel D'avella, Daniel Williams, Jordan Ballew, Nick Murphy, Priyank Lodha, Thomas Robitaille, Yash Krishan, Andrew Hill, Arthur Eigenbrot, Benjamin Mampaey, Bernhard Wiedemann, Carlos Molina 0002, Duygu Keskek, Ishtyaq Habib, Joseph Letts, Juanjo Bazán, Quinn Arbolante, Reid Gomillion, Yash Kothari, Yash Sharma, Abigail Stevens, Adrian M. Price-Whelan, Ambar Mehrotra, Arseniy Kustov, Brandon Stone, Trung Dang, Emmanuel Arias, Fionnlagh Dover, Freek Verstringe, Gulshan Kumar, Harsh Mathur, Igor Babuschkin, Jaylen Wimbish, Juan Buitrago-Casas, Kalpesh Krishna, Kaustubh Hiware, Manas Mangaonkar, Matthew Mendero, Mickaël Schoentgen, Norbert Gyenge, Ole Streicher, Rajasekhar Mekala, Rishabh Mishra, Shashank Srikanth, Sarthak Jain, Tannmay Yadav, Tessa Wilkinson, Tiago Pereira, Yudhik Agrawal, Jamescalixto, Yasintoda, Sophie Murray, David Pérez–Suárez, K Vishnunarayan, Himanshu No Last Name, Ankit Agrawal, Jacob No Last Name, Ankit No Last Name, Daniel D’Avella, Nicholas A. Murphy, Carlos MolinaJ. Open Source Softw 2020 · DOI · DBLP

Introduction

SunPy is the foundational community-developed Python library designed to provide a standardized, open-source ecosystem for solar data analysis. By bridging the gap between raw telescope observations and the modern scientific Python stack, it enables researchers to search, download, and analyze high-resolution solar data through a unified and extensible interface.

Addressing the Solar Data Challenge

Solar physics presents unique data challenges. Because the Sun is our closest star, it is observed with spatial and temporal resolutions orders of magnitude higher than any other astronomical object. This proximity results in massive, complex datasets from a wide variety of space-based and ground-based observatories, each with its own metadata conventions and data formats.

Historically, the field lacked a unified, open-source framework, often relying on fragmented or proprietary tools. Solar physicists needed a way to handle specialized tasks—such as transforming Sun-centered coordinates, accounting for the Sun's differential rotation, and managing complex FITS (Flexible Image Transport System) headers—within the broader ecosystem of tools like NumPy and Matplotlib.

Core Architecture and Visualization

SunPy is built as a modular "core" package that integrates seamlessly with the standard scientific Python stack (numpy, scipy, matplotlib, and pandas) and specifically extends astropy. Its architecture is defined by several key subpackages:

  • sunpy.net: A unified search and retrieval interface that abstracts the complexity of different data providers, allowing users to query and download data from 18 different solar observatories through a single API.
  • sunpy.map and sunpy.timeseries: Core data structures designed to handle 2D image data and 1D temporal data, respectively. These classes automatically parse solar-specific metadata and World Coordinate Systems (WCS), ensuring that physical units and spatial orientations are handled correctly during analysis.
  • sunpy.coordinates: An extension of astropy.coordinates that implements Sun-centered coordinate frames. This is essential for tracking features like solar flares or magnetic loops as they move across the solar disk or through the heliosphere.
Example of SunPy's visualization capabilities: a GOES X-ray flux time-series (left) and an SDO/AIA solar map with coordinate overlays (right).

Key Insights and Results

SunPy emphasizes standardization over fragmentation. By providing a "standard" interface for disparate instruments, researchers can focus on the physics of the Sun rather than the "data munging" required to make different datasets talk to each other. The library follows an "affiliated package" model, where the core library handles foundational tasks, while specialized needs (like radio spectroscopy or multi-dimensional data cubes) are handled by separate but compatible packages like radiospectra and ndcube.

Key achievements of the project include:

  • Unified Data Access: Successful integration of 18 major solar data sources into a single search/download framework.
  • Interoperability: Full compatibility with the astropy ecosystem, ensuring that solar physics is no longer a "software island" but part of the broader astronomical community.
  • Visualization: Built-in methods for generating publication-quality plots of solar maps and time-series data that automatically handle coordinate projections and unit scaling.
  • Community Growth: The project has matured into a NumFOCUS sponsored project, signaling its stability and importance to the scientific community.

Future Directions

While SunPy provides a robust core, the ecosystem is constantly evolving. Future work focuses on expanding instrument support for new missions like Solar Orbiter and the Parker Solar Probe, maturing the suite of affiliated packages for multi-dimensional data, and optimizing performance for "big data" solar physics.

Summary updated

BibTeX
@article{mumford2020sunpy,
  author = {Stuart Mumford and Nabil Freij and Steven Christe and Jack Ireland and Florian Mayer and V. Keith Hughitt and Albert J. Shih and Daniel Ryan and Simon Liedtke and David Pérez-Suárez and Pritish Chakraborty and Vishnunarayan K and Andrew Inglis and Punyaslok Pattnaik and Brigitta M. Sipocz and Rishabh Sharma and Andrew Leonard and David Stansby and Russell J. Hewett and Alex Hamilton and Laura Hayes and Asish Panda and Matt Earnshaw and Nitin Choudhary and Ankit Kumar and Prateek Chanda and Md. Akramul Haque and Michael Kirk and Michael Mueller and Sudarshan Konge and Rajul Srivastava and Yash Jain and Samuel Bennett and Ankit Baruah and Will T. Barnes and Michael Charlton and Shane A. Maloney and Nicky Chorley and Himanshu and Sanskar Modi and James Mason and Jose Rozo and Larry Manley and Agneet Chatterjee and John Evans and Michael Malocha and Monica G. Bobra and Sourav Ghosh and Dominik Stanczak and Ruben De Visscher and Shresth Verma and Ankit Agrawal and Dumindu Buddhika and Swapnil Sharma and Jongyeob Park and Matt Bates and Dhruv Goel and Garrison Taylor and Goran Cetusic and Jacob and Mateo Inchaurrandieta and Sally Dacie and Sanjeev Dubey and Deepankar Sharma and Erik Bray and Jai Rideout and Serge Zahniy and Tomas Meszaros and Abhigyan Bose and André Chicrala and Ankit and Chloé Guennou and Daniel D'avella and Daniel Williams and Jordan Ballew and Nick Murphy and Priyank Lodha and Thomas Robitaille and Yash Krishan and Andrew Hill and Arthur Eigenbrot and Benjamin Mampaey and Bernhard Wiedemann and Carlos Molina and Duygu Keskek and Ishtyaq Habib and Joseph Letts and Juanjo Bazán and Quinn Arbolante and Reid Gomillion and Yash Kothari and Yash Sharma and Abigail Stevens and Adrian M. Price-Whelan and Ambar Mehrotra and Arseniy Kustov and Brandon Stone and Trung Dang and Emmanuel Arias and Fionnlagh Dover and Freek Verstringe and Gulshan Kumar and Harsh Mathur and Igor Babuschkin and Jaylen Wimbish and Juan Buitrago-Casas and Kalpesh Krishna and Kaustubh Hiware and Manas Mangaonkar and Matthew Mendero and Mickaël Schoentgen and Norbert Gyenge and Ole Streicher and Rajasekhar Mekala and Rishabh Mishra and Shashank Srikanth and Sarthak Jain and Tannmay Yadav and Tessa Wilkinson and Tiago Pereira and Yudhik Agrawal and Jamescalixto and Yasintoda and Sophie Murray and Stuart Mumford and Nabil Freij and Steven Christe and J. Ireland and Florian Mayer and V. Keith Hughitt and Albert Y. Shih and Daniel F. Ryan and Simon Liedtke and David Pérez–Suárez and K Vishnunarayan and Andrew Inglis and Punyaslok Pattnaik and Brigitta Sipőcz and Andrew J. Leonard and David Stansby and Russell J. Hewett and Alex Hamilton and Laura A. Hayes and Asish Panda and Matt Earnshaw and Nitin Choudhary and Md Enamul Haque and Michael S. Kirk and Michael Mueller and Sudarshan Konge and Rajul Srivastava and Samuel Bennett and Ankit Kumar Baruah and Will Barnes and Michael Charlton and Shane A. Maloney and Nicky Chorley and Himanshu No Last Name and Sanskar Modi and James Mason and J. I. Campos Rozo and Larry Manley and John Evans and Michael Malocha and Monica Bobra and Dominik Stańczak and Ruben De Visscher and Ankit Agrawal and Dumindu Buddhika and Swapnil Sharma and Jongyeob Park and Matt Bates and Dhruv Goel and Garrison Taylor and Goran Cetušić and Jacob No Last Name and Mateo Inchaurrandieta and Sally Dacie and Sanjeev Dubey and Deepankar Sharma and Erik M. Bray and Jai Ram Rideout and S. Zahniy and Tomas Meszaros and Abhigyan Bose and André Chicrala and Ankit No Last Name and C. Guennou and Daniel D’Avella and D. R. Williams and Jordan Ballew and Nicholas A. Murphy and Priyank Lodha and Thomas Robitaille and Yash Krishan and Arthur Eigenbrot and Benjamin Mampaey and Bernhard Wiedemann and Carlos Molina and Duygu Keşkek and Ishtyaq Habib and J. Letts and Juanjo Bazán and Quinn Arbolante and Reid J. Gomillion and Abigail Stevens and Adrian M. Price-Whelan and Ambar Mehrotra and Arseniy Kustov and Brandon Stone and Trung Kien Dang and Emmanuel Arias and Fionnlagh Mackenzie Dover and Andrew Hill and Ankit Kumar and Prateek Chanda and Rishabh Sharma and Sourav Ghosh and Yash Kothari and Yash Sharma},
  title = {{SunPy: A Python package for Solar Physics}},
  journal = {J. Open Source Softw.},
  year = {2020},
  doi = {10.21105/joss.01832},
}

Loading related content...

Figure