Repository: sunpy/sunpy

Issue:
Calling `.resample()` on HMI submap reverses sign on x- and y-axis 
I don't know whether this is a bug or I am just not understanding what is going on here. 

I understand that HMI data is rotated 180 deg. (relative to say, AIA) (per #1847). When a submap is created, the results are expected, with just the direction of the axes reversed. However, when the same submap is resampled, the x and y axes change signs though the ROI is the same. See example below.
## MWE

``` Python
from sunpy.net import vso
from sunpy.map import Map
client = vso.VSOClient()
result_hmi = client.query(
   vso.attrs.Time((2011, 2, 14, 20, 34, 0), (2011, 2, 14, 21, 0, 0)), 
   vso.attrs.Instrument('HMI'),              
   vso.attrs.Physobs('LOS_magnetic_field'),  
   vso.attrs.Sample(4000 * u.s)
 )
data_hmi = client.get(result_hmi, methods=('URL-FILE_Rice', 'URL-FILE')).wait()
hmi_map = sunpy.map.Map(data_hmi[0])
hmi_submap = hmi_map.submap(u.Quantity([50,300]*u.arcsec),u.Quantity([-350,-100]*u.arcsec))
hmi_submap_resampled = hmi_submap.resample(u.Quantity([20,20]*u.pixel),method='linear')
hmi_map.peek()
hmi_submap.peek()
him_submap_resampled.peek()
```

![image](https://cloud.githubusercontent.com/assets/8676141/17190836/f04656f2-540c-11e6-989e-40fc6ffd4fb2.png)
![image](https://cloud.githubusercontent.com/assets/8676141/17191092/08f00b20-540e-11e6-9fe5-f7e94424ee62.png)
![image](https://cloud.githubusercontent.com/assets/8676141/17191095/0d2af04c-540e-11e6-8135-61d5f8daa7db.png)



Discussion:
I think this was raised in IRC on Monday. It smells of bug.

~~For what it's worth, if you first resample and then crop, this problem does **not** occur.~~

**EDITED**: Sign change does not show up in `.peek()` when resampling and then cropping, but using `xrange` and `yrange` attributes shows that they are indeed still the wrong sign. 

ok, so there is something wonky in the resample code.

I knew this day would come. It is time to work out what `map.center` does because it's broken: https://github.com/sunpy/sunpy/blob/master/sunpy/map/mapbase.py#L446

According to this: https://github.com/sunpy/sunpy/blob/master/sunpy/wcs/wcs.py#L80 it "returns the centre of the image in data coordinates", so is that not the same as doing `map.pixel_to_data(map.dimensions/2)` ?? 

To add to the confusion, this problem does not _seem_ to show up in AIA maps. So maybe this is a result of the reversal of the HMI axes to account for the 180 deg. rotation?

Is submap making an assumption about axis orientation?  See beginning at line 1146 of mapbase.py

@larrymanley that seems likely since calling `.rotate(angle=180.*u.degree)` on the HMI map before resampling/cropping (in either order) fixes this problem. 


Resolving patch:
diff --git a/sunpy/map/mapbase.py b/sunpy/map/mapbase.py
--- a/sunpy/map/mapbase.py
+++ b/sunpy/map/mapbase.py
@@ -452,14 +452,10 @@ def yrange(self):
     @property
     def center(self):
         """
-        The offset between the center of the Sun and the center of the map.
+        Return the world (data) coordinates of the center pixel of the array.
         """
-        return Pair(wcs.get_center(self.dimensions[0], self.scale.x,
-                                   self.reference_pixel.x,
-                                   self.reference_coordinate.x),
-                    wcs.get_center(self.dimensions[1], self.scale.y,
-                                   self.reference_pixel.y,
-                                   self.reference_coordinate.y))
+        center = u.Quantity(self.dimensions) / 2.
+        return Pair(*self.pixel_to_data(*center))
 
     @property
     def shifted_value(self):


Test patch:
diff --git a/sunpy/physics/tests/test_solar_rotation.py b/sunpy/physics/tests/test_solar_rotation.py
--- a/sunpy/physics/tests/test_solar_rotation.py
+++ b/sunpy/physics/tests/test_solar_rotation.py
@@ -42,15 +42,15 @@ def aia171_test_mapcube(aia171_test_submap):
 # Known displacements for these mapcube layers when the layer index is set to 0
 @pytest.fixture
 def known_displacements_layer_index0():
-    return {'x': np.asarray([1.222134e-12, -9.142634e+00, -1.830314e+01]),
-            'y': np.asarray([1.506351e-12, 1.955316e-01, 3.805245e-01])}
+    return {'x': np.asarray([ -2.64321898e-12, -9.10078156e+00, -1.82203188e+01]),
+            'y': np.asarray([ -3.35376171e-12,  2.06812274e-01,  4.03135364e-01])}
 
 
 # Known displacements for these mapcube layers when the layer index is set to 1
 @pytest.fixture
 def known_displacements_layer_index1():
-    return {'x': np.asarray([9.123862e+00, 6.821210e-13, -9.142596e+00]),
-            'y': np.asarray([-2.061722e-01, 9.663381e-13, 1.956522e-01])}
+    return {'x': np.asarray([9.08112778e+00, 5.62749847e-12, -9.10074423e+00]),
+            'y': np.asarray([-2.17404844e-01, 7.16227078e-12, 2.06935463e-01])}
 
 
 def test_calculate_solar_rotate_shift(aia171_test_mapcube, known_displacements_layer_index0, known_displacements_layer_index1):
diff --git a/sunpy/tests/figure_hashes.json b/sunpy/tests/figure_hashes.json
--- a/sunpy/tests/figure_hashes.json
+++ b/sunpy/tests/figure_hashes.json
@@ -5,11 +5,11 @@
     "sunpy.map.tests.test_mapbase.test_peek_grid_limb_aia171": "a3b29a16745ed4907355b67df1fca77f3b08e538d2aa57bf4f7699de96851a79",
     "sunpy.map.tests.test_mapbase.test_peek_limb_aia171": "7487150aa673bbb748ad237ebbc90159bcc2642ee03329373eae26d2003dfb49",
     "sunpy.map.tests.test_mapbase.test_plot_aia171": "422993a931b27ce96ed73b0fa68ab8630c1c62b27680329ffce0760e7629c614",
-    "sunpy.map.tests.test_mapbase.test_plot_aia171_nowcsaxes": "39964acef0d7de0120d9fcb5e9131bb17364d47bc22eb88d23f6075a7f1447cd",
-    "sunpy.map.tests.test_mapbase.test_plot_aia171_superpixel": "535692f6c1cf53586a560fdfd5495a2381c4c1a3a89085846a60889cf301a8eb",
-    "sunpy.map.tests.test_mapbase.test_plot_aia171_superpixel_nowcsaxes": "195206ae75854cd36e1fa9c16d24cd8e46f79b449c8ce3acf686c216606bfad3",
+    "sunpy.map.tests.test_mapbase.test_plot_aia171_nowcsaxes": "bfee3590f64b8025b7790488afeaa0bbe88a42ffdffd37f2cb54996da172dab3",
+    "sunpy.map.tests.test_mapbase.test_plot_aia171_superpixel": "4dde4efcbf7e535632e3ad333258c99207616b7cb4f86cb5f4a43001d81f8eb8",
+    "sunpy.map.tests.test_mapbase.test_plot_aia171_superpixel_nowcsaxes": "3c31344466c9394f707e8e2a71ad36e50af7c52923242520ec1e8b20597df933",
     "sunpy.map.tests.test_mapbase.test_plot_masked_aia171": "70f57e4f293aec75548b16ed19eef4e651789e8ab88d4579d5ee236d5c447dfe",
-    "sunpy.map.tests.test_mapbase.test_plot_masked_aia171_nowcsaxes": "82cb4bcfd87b5938dff1cb20a9e86460638676164718017defab60e0268a002c",
-    "sunpy.map.tests.test_mapbase.test_plot_masked_aia171_superpixel": "6574a682ba84311730a57adae57e59294e622705ee48790171ee00e643b8ad28",
-    "sunpy.map.tests.test_mapbase.test_plot_masked_aia171_superpixel_nowcsaxes": "de79b98ce38186ef2b73b72e098509983b0efe27f6dc5ab60c4fccc97a8f27b8"
+    "sunpy.map.tests.test_mapbase.test_plot_masked_aia171_nowcsaxes": "f99d46fd70c97cd85904a956b570fef5a9909a1d7f3ea952a66d12b7682eaafc",
+    "sunpy.map.tests.test_mapbase.test_plot_masked_aia171_superpixel": "d75073abc5220e1c68faf691338a87ad087d401eeb76a1328f5ea0acf9aff238",
+    "sunpy.map.tests.test_mapbase.test_plot_masked_aia171_superpixel_nowcsaxes": "ccd56c276a52f7eb30896fb35618cc052723d082a4f460fb8bf11364dcf15588"
 }
\ No newline at end of file