sunpy/sunpy — pull request #1009 by ayshih (2014-05-28 04:24:01+00:00)
Title: Fixing `map.rotate()`

Here's my proposed solution for how to fix `map.rotate()` (see #923) in the current state of the code, without putting it off until we have a new WCS implementation.

Changes:
* The reference pixel/coordinate is redefined in `meta` according to a rotation about the rotation axis (`rotation_center`). By default, the rotation axis is the origin in the coordinate system (i.e., (0, 0) ), but you can specify it to be something else in data space (not pixel space).
* Rotation goes the "correct" direction (CCW)
* A new rotation angle is written to `meta` using the CROTA2 convention. If a rotation angle is already defined (e.g., HMI data), the difference is what is stored.
* If one calls `rotate()` without specifying any angle or rotation matrix, the map will be rotated by the rotation angle attribute (which is currently read straight from the CROTA2 tag). Note that because of the preceding bullet, the rotated map will have a zero rotation angle in its metadata.
* Removed the "recenter" functionality because it was confusing. `rotate()` no longer has any ability to do translation.
* `angle` argument now expects degrees rather than radians, because the latter was unnecessarily complicating

Example:
```python
import sunpy.map
m1 = sunpy.map.Map(sunpy.AIA_171_IMAGE).submap([0, 1200], [0, 1200], 'data')
m2 = m1.rotate(30)
m3 = m1.rotate(30, rotation_center=(740, 370))

m1.peek()
```
![m1](https://cloud.githubusercontent.com/assets/991759/3100622/95c8040a-e61d-11e3-8aa5-af05cb6160d6.png)
```python
m2.peek()
```
![m2](https://cloud.githubusercontent.com/assets/991759/3100635/f67480bc-e61d-11e3-80e2-a2691434da07.png)

You can see that the limb is being drawn correctly, which demonstrates that the HPC origin is the fixed point of the rotation.

```python
m3.peek()
```
![m3](https://cloud.githubusercontent.com/assets/991759/3100658/7511e0e0-e61e-11e3-8859-a1cb476949a4.png)

Here I have arbitrarily defined the rotation axis to be at (740, 370) in HPC coordinates. Note that the data array is rotated by the same 45 degrees as the previous example, but it is the coordinates that are now defined differently. The solar limb no longer matches the data because the HPC origin is no longer the fixed point of the rotation.