Rotating a Map

How to rotate a map.

import astropy.units as u

import matplotlib.pyplot as plt

import sunpy.map
import sunpy.data.sample

We start with the sample data

aia_map = sunpy.map.Map(sunpy.data.sample.AIA_171_IMAGE)

GenericMap provides the rotate method which accepts an angle. This returns a rotated map and does not rotate in place. The data array size is expanded so that none of the original data is lost due to clipping. Note that subsequent rotations are not compounded. The map is only rotated by the specified amount from the original maps orientation.

aia_rotated = aia_map.rotate(angle=30 * u.deg)

Out:

/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.7/site-packages/astropy/units/quantity.py:1072: AstropyDeprecationWarning: The truth value of a Quantity is ambiguous. In the future this will raise a ValueError.
  AstropyDeprecationWarning)
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.7/site-packages/sunpy-1.0.3.dev1+gece6362cd-py3.7-linux-x86_64.egg/sunpy/image/transform.py:121: SunpyUserWarning: Input data has been cast to float64.
  warnings.warn("Input data has been cast to float64.", SunpyUserWarning)

Let’s now plot the results.

fig = plt.figure()
ax = plt.subplot(projection=aia_rotated)
aia_rotated.plot()
aia_rotated.draw_limb()
aia_rotated.draw_grid()
plt.show()
../../../_images/sphx_glr_map_rotation_001.png

Total running time of the script: ( 0 minutes 2.483 seconds)

Gallery generated by Sphinx-Gallery