SunPy - Python for Solar Physics

Stuart Mumford

The University of Sheffield, UK

Things you should know:

  1. You can use SunPy for your research. (probably)
  2. You should join the SunPy community.


Slides here: http://stuartmumford.uk/talks/ras2016/

What is SunPy?

"A Project to facilitate and promote the use and development of a community-led, free and open-source solar data-analysis software based on the scientific Python environment."

A library designed to provide core functionality to enable people to do solar physics with Python.

A community of solar physicists doing science using Python.

Why Python?

  1. Python is being widely adopted as a scientific programming language.
  2. Easy to learn.
  3. A lot of new astronomical code is being written in Python, i.e. JWST & DKIST pipelines.
  4. A lot of domain experts write packages in Python, that you can use!
  5. Python is widely used outside of acedemia.
  6. A very transferable skill.
  7. Very flexible, can wrap C or FORTRAN code when you have a need for speed.
  8. many many more...

SunPy is a Gateway

Major Features of SunPy

  • Data Structures for Images, Spectra, and Time Series Data.
  • Data Retrival code, from VSO, JSOC, HEK, Helio, and other places.
  • Versioned Library Releases, with clear upgrade paths.
  • High quality documentation.

A Plot!

In [7]:
# Create a AIA 171 Map from some sample data
mymap = sunpy.map.Map(AIA_171_ROLL_IMAGE)

# Plot the AIA Map object
im = mymap.plot()

#Make the HP grid larger so it can be seen on the projector
plt.gca().coords.grid(color='white', lw=3)

# Overlay the Heliographic Coordinate Grid
l = mymap.draw_grid()

Searching the VSO

In [29]:
from sunpy.net import vso
from sunpy.net.vso import attrs as a

vc = vso.VSOClient()
results = vc.query(a.Time('2015/12/1T00:00:20', '2015/12/1T00:00:25'),
                   a.Instrument('AIA') | a.Instrument('HMI'))
results
Out[29]:
<Table masked=False length=7>
Start Time [1]End Time [1]SourceInstrumentType
string152string152string24string24string64
2015-12-01 00:00:222015-12-01 00:00:23SDOAIAFULLDISK
2015-12-01 00:00:222015-12-01 00:00:23SDOAIAFULLDISK
2015-12-01 00:00:242015-12-01 00:00:25SDOAIAFULLDISK
2015-12-01 00:00:252015-12-01 00:00:26SDOAIAFULLDISK
2015-12-01 00:00:242015-12-01 00:00:25SDOHMIFULLDISK
2015-12-01 00:00:242015-12-01 00:00:25SDOHMIFULLDISK
2015-12-01 00:00:242015-12-01 00:00:25SDOHMIFULLDISK
In [ ]:
vc.get(results, path="/home/stuart/sunpy/data/{instrument}/{file}").wait()

Workshops

  • Software Carpentry style workshops, with extra days for SunPy and Astropy.
  • First one March 2015.
  • Next one next week! (Still spaces)
  • Material online (https://github.com/OpenAstronomy/workshop_sunpy_astropy).
  • We will run one for you!