Exploring Our Star with SunPy

1

Python, one of the foremost high-level programming languages, has played a growing role in the analysis of astronomical data. With the recent release of a new software package, SunPy, it’s now easier than ever for solar physicists to use Python as well.

SDO/AIA

An example of a SunPy-generated Map visualization using data from the Solar Dynamics Observatory’s AIA instrument. The bottom panel shows a zoomed-in view from the top panel, focusing on an erupting flare. [Adapted from The SunPy Community et al. 2020]

Juggling Ones and Zeros

The modern era of astronomy relies heavily on computer software to advance our understanding of the universe. Long gone are the days of sketching what we see through telescope eyepieces; now astronomers receive their telescope observations in the form of files full of data that must be carefully analyzed using complex code bases.

Preferences for one programming language over another evolve over time as our needs evolve — and Python is currently a rising star. Major companies like Google, Wikipedia, and Facebook all make use of Python, and astronomers are increasingly adopting Python for their data analysis in place of past staples like Fortran and IDL.

A Shared Enterprise

The field of solar physics is driven by publicly available observations of the Sun that stream in on a constant basis from a number of ground- and space-based observatories. As solar physics, like the rest of astronomy, is a largely collaborative field, it makes sense to share the software tools that are used to analyze this common data.

To this end, a group of solar physicists has come together to produce SunPy, a community-developed free and open-source software package that consists of tools for analyzing solar and heliospheric data. In a recent article, the SunPy team has detailed this Python-based package and the overarching SunPy project, which develops and maintains the package and supports the ecosystem surrounding it.

SunPy codebase

Growth of the SunPy codebase over time — both the total lines of code (solid line) and comments (dashed line). The dip after version 0.9 is the result of a major code reorganization. [The SunPy Community et al. 2020]

What Can SunPy Do For You?

Looking to explore some solar data? The SunPy software package is freely accessible, and its first official stable release was issued last year. As of version 1.0, SunPy consisted of nearly 50,000 lines of code, comments, and documentation that support a large set of common tasks in the analysis of solar data.

Here are just a few things you can do using the SunPy package:

  • Query and download data from many different solar missions and instruments via a general, standard, and consistent interface.
  • Load and visualize time series data — measurements of how, say, a particular type of flux from a region changes over time — and images.
  • Perform transformations between the variety of coordinate systems commonly used to describe events and features both on the Sun and within the heliosphere.
SunPy Gallery

SunPy comes with a detailed user’s guide and example gallery to assist users. [SunPy]

Looking Ahead

SunPy will be supported with two new releases planned per year. Future development already on the books includes support for generic spectra, multidimensional data sets, and a standardized approach to metadata.

The SunPy team hopes to grow community involvement and establish financial support in the future, in order to further expand SunPy development. In the meantime, the SunPy project’s team of volunteer developers have done an admirable job of building a powerful set of shared tools for the solar physics community.

Citation

“The SunPy Project: Open Source Development and Status of the Version 1.0 Core Package,” The SunPy Community et al 2020 ApJ 890 68. doi:10.3847/1538-4357/ab4f7a