How-To Guides#

These how-to guides provide examples of how to perform specific tasks with sunpy. They are recipes that do not provide much in-depth explanation and assume you have some knowledge of what sunpy is and how it works. If you’re starting fresh you might want to check out the The sunpy tutorial first.

Quick Reference

The following table is meant as a quick reference. For more complete code examples, see the how-to guides above.

How do I…

Solution

create a map from a FITS file

my_map = Map('file.fits')

save a map to a FITS file

my_map.save('another_file.fits')

get a quicklook summary of a map

my_map.quicklook(), my_map.peek()

plot a map

my_map.plot()

access the underlying data array of a map

my_map.data

access the map metadata

my_map.meta

make a copy of the map data array

my_map.data.copy()

make a copy of the whole map

copy.deepcopy(my_map)

access the observer location

my_map.observer_coordinate

remove the roll angle

my_map.rotate()

plot the solar limb

my_map.draw_limb()

overlay a heliographic grid

my_map.draw_grid()

create a time series

my_timeseries = TimeSeries('file.nc')

plot a time series

my_timeseries.plot()

concatenate two time series together

my_timeseries.concatenate(another_timeseries)

convert a time series to a pandas.DataFrame

my_timeseries.to_dataframe()

convert a time series to an astropy.table.Table

my_timeseries.to_table()

parse the string representation of a timestamp

parse_time()

calculate the Carrington rotation number at a given time

carrington_rotation_number()

calculate the time corresponding to a given Carrington rotation

carrington_rotation_time()

see all of the available solar constants

sunpy.sun.constants.print_all()