Repository: sunpy/sunpy

Issue:
Changes after Astropy 3.1
This issue is a list of changes that can be made once we drop support for Astropy 3.1 (i.e. depend on Astropy 3.2+)

## Coordinates

- [x] [#3919] Change `get_horizons_coord()` to use `HeliocentricEclipticIAU76` to be more accurate
- ~Change `apparent_longitude()` and `apparent_latitude()` to use `GeocentricTrueEcliptic` (no change in accuracy)~  Using `GeocentricTrueEcliptic` gives incorrect answers, so I need to confirm whether this is a bug in Astropy's definition.  Update: confirmed to be a bug and fixed in astropy/astropy#10129
- [x] [#4005] Remove `try`...`except` blocks for importing `HeliocentricMeanEcliptic` and `GeocentricMeanEcliptic`
- [x] [#4005] Remove the `try`...`except` block for importing `make_transform_graph_docs` in coordinates.
- [x] [#4005] Simplify the [saving/loading example](https://docs.sunpy.org/en/latest/generated/gallery/saving_and_loading_data/coordinates_in_asdf.html) because SkyCoord can be saved

## Visualization

- [ ] `ArrayAnimatorWCS` has a compatibility wrapper for `Quantity.to_string`. [#3407]


Discussion:
> * Change `get_horizons_coord()` to use `HeliocentricEclipticIAU76` to be more accurate

I finally checked, and making this change decreases the discrepancy for the position of Earth from tens of kilometers to a few kilometers.  If I also make Astropy use a JPL ephemeris rather than its built-in ephemeris, the discrepancy drops to below a *meter* (not kilometer).
Does this still need to be done? I can work on this.
@Cubostar This will need to be done, but not now.  We need to wait until SunPy depends on Astropy 3.2, and there isn't a compelling reason yet to bump up the dependency.
@ayshih I have hijacked this for all Astropy 3.1 compatibility changes.
I think we have decided that we are 3.2+ for 2.0 right? If so we should make all these changes?

Resolving patch:
diff --git a/sunpy/visualization/animator/base.py b/sunpy/visualization/animator/base.py
--- a/sunpy/visualization/animator/base.py
+++ b/sunpy/visualization/animator/base.py
@@ -620,7 +620,9 @@ def update_plot(self, val, artist, slider):
         # Update slider label to reflect real world values in axis_ranges.
         label = self.axis_ranges[ax_ind](ind)
         if isinstance(label, u.Quantity):
-            slider.valtext.set_text(format_quantity_as_string(label))
+            slider.valtext.set_text(label.to_string(precision=5,
+                                                    format='latex',
+                                                    subfmt='inline'))
         elif isinstance(label, str):
             slider.valtext.set_text(label)
         else:
@@ -647,17 +649,3 @@ def edges_to_centers_nd(axis_range, edges_axis):
     lower_edges = axis_range[tuple(lower_edge_indices)]
 
     return (upper_edges - lower_edges) / 2 + lower_edges
-
-
-def format_quantity_as_string(quantity):
-    """
-    An Astropy 3.1 compatibility wrapper for Quantity.to_string.
-    Can be removed when Astropy dependency is >=3.2
-    """
-    to_string = getattr(quantity, "to_string", None)
-    if not to_string:
-        return quantity._repr_latex_()
-    else:
-        return quantity.to_string(precision=5,
-                                  format='latex',
-                                  subfmt='inline')


Test patch: