Repository: sunpy/sunpy

Issue:
Simplify wcsaxes_compat post astropy 3.1
After we are depending on astropy 3.1+ we can remove a lot of the compatibility code in wcsaxes_compat as there have been many improvements to the defaults with regards to solar data


Discussion:

Resolving patch:
diff --git a/sunpy/map/mapbase.py b/sunpy/map/mapbase.py
--- a/sunpy/map/mapbase.py
+++ b/sunpy/map/mapbase.py
@@ -3,7 +3,6 @@
 """
 import copy
 import warnings
-import inspect
 from collections import namedtuple
 import textwrap
 
@@ -13,7 +12,6 @@
 
 import astropy.wcs
 import astropy.units as u
-from astropy.io import fits
 from astropy.visualization.wcsaxes import WCSAxes
 from astropy.coordinates import SkyCoord, UnitSphericalRepresentation
 
@@ -152,7 +150,8 @@ def __init_subclass__(cls, **kwargs):
         An __init_subclass__ hook initializes all of the subclasses of a given class.
         So for each subclass, it will call this block of code on import.
         This replicates some metaclass magic without the need to be aware of metaclasses.
-        Here we use this to register each subclass in a dict that has the `is_datasource_for` attribute.
+        Here we use this to register each subclass in a dict that has the
+        `is_datasource_for` attribute.
         This is then passed into the Map Factory so we can register them.
         """
         super().__init_subclass__(**kwargs)
@@ -1739,8 +1738,7 @@ def plot(self, annotate=True, axes=None, title=True, **imshow_kwargs):
             ret = axes.imshow(np.ma.array(np.asarray(self.data), mask=self.mask), **imshow_args)
 
         if wcsaxes_compat.is_wcsaxes(axes):
-            wcsaxes_compat.default_wcs_grid(axes, units=self.spatial_units,
-                                            ctypes=self.wcs.wcs.ctype)
+            wcsaxes_compat.default_wcs_grid(axes)
 
         # Set current image (makes colorbar work)
         plt.sca(axes)
diff --git a/sunpy/visualization/animator/mapsequenceanimator.py b/sunpy/visualization/animator/mapsequenceanimator.py
--- a/sunpy/visualization/animator/mapsequenceanimator.py
+++ b/sunpy/visualization/animator/mapsequenceanimator.py
@@ -80,10 +80,6 @@ def updatefig(self, val, im, slider):
 
         if wcsaxes_compat.is_wcsaxes(im.axes):
             im.axes.reset_wcs(self.mapsequence[i].wcs)
-            wcsaxes_compat.default_wcs_ticks(im.axes,
-                                             self.mapsequence[i].spatial_units,
-                                             self.mapsequence[i].coordinate_system)
-
         # Having this line in means the plot will resize for non-homogenous
         # maps. However it also means that if you zoom in on the plot bad
         # things happen.
diff --git a/sunpy/visualization/wcsaxes_compat.py b/sunpy/visualization/wcsaxes_compat.py
--- a/sunpy/visualization/wcsaxes_compat.py
+++ b/sunpy/visualization/wcsaxes_compat.py
@@ -10,8 +10,8 @@
 # It should only be used by tests and other such hacks.
 _FORCE_NO_WCSAXES = False
 
-__all__ = ["is_wcsaxes", "gca_wcs", "get_world_transform", "solar_coord_type_from_ctype",
-           "default_wcs_ticks", "wcsaxes_heliographic_overlay"]
+__all__ = ["is_wcsaxes", "gca_wcs", "get_world_transform",
+           "default_wcs_grid", "wcsaxes_heliographic_overlay"]
 
 
 def is_wcsaxes(axes):
@@ -97,65 +97,7 @@ def get_world_transform(axes):
     return transform
 
 
-def solar_coord_type_from_ctype(ctype):
-    """
-    Determine whether a particular `~astropy.wcs.WCS` ctype corresponds to an
-    angle or scalar coordinate.
-    """
-    if ctype[2:4] == 'LN':
-        if ctype[:4] in ['HPLN', 'HGLN']:
-            return 'longitude', 180.
-        return 'longitude', None
-    elif ctype[2:4] == 'LT':
-        return 'latitude', None
-    else:
-        return 'scalar', None
-
-
-def default_wcs_ticks(axes, units, ctypes):
-    """
-    Set the ticks on a `~astropy.visualization.wcsaxes.WCSAxes` plot.
-    """
-    if not isinstance(axes, wcsaxes.WCSAxes):
-        raise TypeError("This axes is not a WCSAxes")
-
-    x = axes.coords[0]
-    y = axes.coords[1]
-
-    if x.ticks.get_tick_out() == 'in':
-        x.set_ticks(color='white')
-    if y.ticks.get_tick_out() == 'in':
-        y.set_ticks(color='white')
-
-    x.set_ticks_position('bl')
-    y.set_ticks_position('bl')
-
-    xtype = solar_coord_type_from_ctype(ctypes[0])
-    ytype = solar_coord_type_from_ctype(ctypes[1])
-
-    x.set_coord_type(*xtype)
-    y.set_coord_type(*ytype)
-
-    if xtype[0] == 'scalar':
-        x.set_major_formatter('x.x')
-    elif units[0] is u.deg:
-        x.set_major_formatter('d.d')
-    elif units[0] is u.arcsec:
-        x.set_major_formatter('s.s')
-    else:
-        x.set_major_formatter('x.x')
-
-    if ytype[0] == 'scalar':
-        x.set_major_formatter('x.x')
-    elif units[1] is u.deg:
-        y.set_major_formatter('d.d')
-    elif units[1] is u.arcsec:
-        y.set_major_formatter('s.s')
-    else:
-        y.set_major_formatter('x.x')
-
-
-def default_wcs_grid(axes, units, ctypes):
+def default_wcs_grid(axes):
     """
     Apply some default `~astropy.visualization.wcsaxes.WCSAxes` grid
     formatting.
@@ -165,10 +107,7 @@ def default_wcs_grid(axes, units, ctypes):
     axes : `~astropy.visualization.wcsaxes.WCSAxes`
         The `~astropy.visualization.wcsaxes.WCSAxes` object to draw the world
         coordinate grid on.
-    units : `tuple`
-        The axes units (``(x, y)`` order).
     """
-    default_wcs_ticks(axes, units, ctypes)
     axes.coords.grid(color='white', alpha=0.6, linestyle='dotted',
                      linewidth=0.5)
 


Test patch:
diff --git a/sunpy/tests/figure_hashes_py36.json b/sunpy/tests/figure_hashes_py36.json
--- a/sunpy/tests/figure_hashes_py36.json
+++ b/sunpy/tests/figure_hashes_py36.json
@@ -1,23 +1,23 @@
 {
-    "sunpy.map.tests.test_plotting.test_draw_contours_aia": "e50435ce87c952c53bd6b4ebb0a48c0a3830ee89a7c9cf04dd50b70f4ba1b817",
-    "sunpy.map.tests.test_plotting.test_draw_grid_aia171": "3743a421155de34d38185be135a09cc8ae6b2148f395753606a001d650ab1a10",
-    "sunpy.map.tests.test_plotting.test_heliographic_peek": "2ffb3d401c4dea63d169d72642afa263285db15f8a9a72a285007aac309d5b7b",
-    "sunpy.map.tests.test_plotting.test_heliographic_rectangle": "07198f053b099b7f76772a673cfe2dbcc746b8b30ae345e989c866c7dab13562",
-    "sunpy.map.tests.test_plotting.test_peek_aia171": "154e3a648bf9b77535bf60d54a8e45fb4ab7f3f3b55a9690d9af5ecedd28c47f",
+    "sunpy.map.tests.test_plotting.test_draw_contours_aia": "576ce31e7cabaf98fa9edc8b802da07c5f0cad24ce6cc0498f4053db267c1d12",
+    "sunpy.map.tests.test_plotting.test_draw_grid_aia171": "ffed81ce2ecf53cb8efc53f75f0c030e328e9dedf6261ae76548c71c8b0f6402",
+    "sunpy.map.tests.test_plotting.test_heliographic_peek": "f826ff27728903a6e5fb7eafe4754df3ea86cf033ed41756155946a0ef6c247c",
+    "sunpy.map.tests.test_plotting.test_heliographic_rectangle": "e366f103b4f96946fb06da1d591b3bdb8ee027eaf387b3ff78b0bb7b5ad69124",
+    "sunpy.map.tests.test_plotting.test_peek_aia171": "bfbe20f58929eb19812b9bbb2c21f4d3fbb7e53defcd00e484ef6c1a943d2222",
     "sunpy.map.tests.test_plotting.test_peek_basic_plot_aia171": "376d4acfbab17abac8d82cbbeb37eb3033281a0a15bc29c6b03c3a6a4d4da43d",
-    "sunpy.map.tests.test_plotting.test_peek_grid_aia171": "0077cdc3ef6356f42a454eafa0c19d4fc9d1a6bedee3dba4e885de2f94ccd942",
-    "sunpy.map.tests.test_plotting.test_peek_grid_limb_aia171": "72a9ef03ff52827347eb29f05705e730be87644b4c308ef02d36d02c063ebb61",
-    "sunpy.map.tests.test_plotting.test_peek_grid_spacing_aia171": "500ef20de32513616b57e409e5b618584dd4f21fd2e7b2362129323299f132b9",
-    "sunpy.map.tests.test_plotting.test_peek_limb_aia171": "85b4ee9cc66740db0b43615a7aa175d44e2aee332cca34e8f85ba513fc566547",
-    "sunpy.map.tests.test_plotting.test_plot_aia171": "07a4a1d29356751a61d634b5ee28752edf1793c87e3f4c64416e29f4a2b1d895",
+    "sunpy.map.tests.test_plotting.test_peek_grid_aia171": "0c5b912605c7d6e08f85e4b1993dc04091c2439157089f081819c0a2defb88d1",
+    "sunpy.map.tests.test_plotting.test_peek_grid_limb_aia171": "9f2f31497ec2fd63cfe4b56dacce1675aefdb92ad344e318a9a51b0b713e2889",
+    "sunpy.map.tests.test_plotting.test_peek_grid_spacing_aia171": "9ddc7026bc6ba47bc79c039e255ed4b1b9e6fdedfbd6c73279390bcd427dab4a",
+    "sunpy.map.tests.test_plotting.test_peek_limb_aia171": "dbee8e3f01517a79b6305e03e52b3b6cdcfb4deb46f6d3d92efdcf6700e73742",
+    "sunpy.map.tests.test_plotting.test_plot_aia171": "eb9784d991df9291be773eaafcdb979bccc3d9d628a88c30369c5bc8c922e2bf",
     "sunpy.map.tests.test_plotting.test_plot_aia171_nowcsaxes": "bb26ffc0b687ec737a65ccfc97b77ec1948db4782dc906b60df80f1bc45750e3",
-    "sunpy.map.tests.test_plotting.test_plot_aia171_superpixel": "cc00fe9faf1985703a6282441b33fa988c9f45c5fa1f45892209f61ca37e5d3e",
+    "sunpy.map.tests.test_plotting.test_plot_aia171_superpixel": "7bd6e4676e97df576d28fcc5405f727175ce4317cf61d6f86662700a6c49312c",
     "sunpy.map.tests.test_plotting.test_plot_aia171_superpixel_nowcsaxes": "cc63ec9ac905682e379519468d5ccdd379d6079fa856f6581d8ae283b4132be3",
-    "sunpy.map.tests.test_plotting.test_plot_masked_aia171": "f0a8498b127b0cb334e8421d547ec92ecb842b4772a349cac2ed5f592229bd8c",
+    "sunpy.map.tests.test_plotting.test_plot_masked_aia171": "ac7d26e4c285e3ab0024ce57d74ba7689999081ef2d40dcd7e542d8279ce0281",
     "sunpy.map.tests.test_plotting.test_plot_masked_aia171_nowcsaxes": "4be823c2955784230627c9ab462acf2c06a51d57b8921aa59466ddb716feafba",
-    "sunpy.map.tests.test_plotting.test_plot_masked_aia171_superpixel": "4023931858c6d6efa84da46a934dba0fbb2eba2a503dd056ba3cf4b9b72d7fea",
+    "sunpy.map.tests.test_plotting.test_plot_masked_aia171_superpixel": "52db52432a9ec8460fcc5ebdbd8fbca6d1f525aee9cb1a308ca311290582e320",
     "sunpy.map.tests.test_plotting.test_plot_masked_aia171_superpixel_nowcsaxes": "d31083ec2f6840f85d53b547313754ede14e2b4d1e703ac8808113b4b59aa4bc",
-    "sunpy.map.tests.test_plotting.test_rectangle_aia171": "e836be091f4c35a2ce8c2ca28d02d75624dfef9d1c40ca26897b57feb9a7ab59",
+    "sunpy.map.tests.test_plotting.test_rectangle_aia171": "a3bdaff65c3f13643bf67e7d6653f49d1818b77666d3ccd102d3179f5c1d8c03",
     "sunpy.timeseries.tests.test_timeseriesbase.test_esp_peek": "2f8995a140d3d0a3ebfbf38c415cd742692ed5338b86672cfe8743e907990572",
     "sunpy.timeseries.tests.test_timeseriesbase.test_eve_peek": "c8cb9d1dba8afbe5da84c7077e1d1c6ff3b9e517eb638a84fb94d5c126b2e4c2",
     "sunpy.timeseries.tests.test_timeseriesbase.test_fermi_gbm_peek": "63d571768516f833f850aea464f7755eadca696a6419549f71862a988c3da36f",
@@ -27,4 +27,4 @@
     "sunpy.timeseries.tests.test_timeseriesbase.test_noaa_pre_peek": "c32301db1b473c2aa9a1e79e8a93f5912c2eb301de2129867199c092cc659321",
     "sunpy.timeseries.tests.test_timeseriesbase.test_norh_peek": "205ac1c35dc47202d30f70d17a93e76099d4b45fec020201a8761306c2a27829",
     "sunpy.timeseries.tests.test_timeseriesbase.test_rhessi_peek": "2227d581e574e0fa9ea62331defe7be17dc6095685c75e2af44348e671bf1ec8"
-}
+}
\ No newline at end of file