What’s New in SunPy 2.0?#
The SunPy project is pleased to announce the 2.0 release of the sunpy package. On this page, you can read about some of the big changes in this release:
SunPy 2.0 also includes a large number of smaller improvements and bug fixes, which are described in the Full Changelog.
By the numbers:
1044 commits have been added since 1.1
144 issues have been closed since 1.1
290 pull requests have been merged since 1.1
33 people have contributed since 1.1
16 new contributors
Increase in required package versions#
We have bumped the minimum version of several packages we depend on:
To search with
Fido, you need to specify attributes to search against.
Before sunpy 2.0, you had to supply values, as the following example demonstrates:
>>> from sunpy.net import Fido, attrs as a >>> Fido.search(a.Time('2012/3/4', '2012/3/6'), a.Instrument("norh"), ... a.Wavelength(17*u.GHz))
There was no way to know if the value was correct, but now we have a extenstive list of supported values from the clients and servers we can request data from.
Instrument as an example, if you print the object:
>>> print(a.Instrument) sunpy.net.attrs.Instrument Specifies the Instrument name for the search. Attribute Name Client Full Name Description --------------------------- ----------- ------------------------ -------------------------------------------------------------------------------- aia VSO AIA Atmospheric Imaging Assembly bbi VSO BBI None bcs VSO BCS Bragg Crystal Spectrometer bic_hifi VSO BIC-HIFI None bigbear VSO Big Bear Big Bear Solar Observatory, California TON and GONG+ sites ...
This will list the name of value you should use, what data source will supply that data and a description.
Furthermore, you can use tab completion to auto-fill the attribute name, for example by typing
So now you can do the following instead:
Fido.search(a.Time('2012/3/4', '2012/3/6'), a.Instrument.norh, a.Wavelength(17*u.GHz))
aiaprep is now deprecated#
With the release of the new aiapy package,
sunpy.instr.aia.aiaprep will be removed in version 2.1.
Equivalent functionality is provided by the
register() function in aiapy. For more
details, see the example on registering and aligning level 1 AIA images
in the aiapy documentation.
Fixes and clarification to pixel indexing#
sunpy uses zero-based indexing when referring to pixels, where the center of the bottom left pixel of a map is at
[0, 0] * u.pix.
Several parts of the API have been updated to make sure this is consistently the case across the package.
sunpy.map.GenericMap.top_right_coordpreviously had an off-by-one error in the calculation of the top right coordinate. This has been fixed.
sunpy.map.GenericMap.centerpreviously had an off-by-one error in the calculation of the coordinate of the center of a map. This has been fixed.
sunpy.map.GenericMap.reference_pixelnow returns a zero-based reference pixel. This is one pixel less than the previously returned value. Note that this means the
reference_pixelnow does not have the same value as the FITS
CRPIXvalues, which are one-based indices.
sunpy.map.header_helper.make_fitswcs_header()now correctly interprets the
reference_pixelargument as being zero-based, in previous releases it incorrectly interpreted the
sunpy.map.GenericMap.draw_rectangle allow specification of “rectangles” in world (spherical) coordinates.
In versions prior to 2.0 you passed the coordinates of the rectangle to
draw_rectangle as a bottom left coordinate, and a height and width, but for submap you passed it as a bottom left and a top right.
In 2.0 the way you call both methods has changed, to accept a bottom left and then either width and height or a top right coordinate.
As part of this change, the
height arguments must always be keyword arguments, i.e.
This change allows you to give the same rectangle specification to
submap as to
Which is especially useful when you wish to plot a cropped area of a map, along with it’s context in the parent map:
>>> import astropy.units as u >>> from astropy.coordinates import SkyCoord >>> import matplotlib.pyplot as plt >>> import sunpy.map >>> from sunpy.data.sample import AIA_171_IMAGE >>> aia = sunpy.map.Map(AIA_171_IMAGE) >>> bottom_left = SkyCoord(-100 * u.arcsec, -100 * u.arcsec, frame=aia.coordinate_frame) >>> width = 500 * u.arcsec >>> height = 300 * u.arcsec >>> sub_aia = aia.submap(bottom_left, width=width, height=height) >>> fig = plt.figure() >>> ax1 = fig.add_subplot(1, 2, 1, projection=aia) >>> aia.plot(axes=ax1) >>> aia.draw_rectangle(bottom_left, width=width, height=height) >>> ax2 = fig.add_subplot(1, 2, 2, projection=sub_aia) >>> sub_aia.plot(axes=ax2)
Both these methods delegate the input parsing to a new utility function
Graphical overview for Map and MapSequence#
There are new methods to produce graphical overviews for
This graphical overview opens the default web browser and uses HTML to show a table of metadata, a histogram of the pixel values in the data, and a histogram-equalized image of the data.
Here’s an example of the output for a