From 9c8632f506ab85d5da47c5b7b6a3aa148ad586f3 Mon Sep 17 00:00:00 2001 From: Ryan May Date: Mon, 23 Dec 2019 01:19:01 -0700 Subject: [PATCH] MNT: Remove outdated CartoPy work-around (Fixes #1229) This was working around CartoPy <=0.14.3 issues for transforming vectors. Latest CartoPy is 0.17.0. 0.15.0 is almost 3 years old at this point, I think we can rely on it. --- setup.cfg | 2 +- src/metpy/plots/station_plot.py | 32 ++------------------------------ 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/setup.cfg b/setup.cfg index 556dddba763..a87995e134c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -53,7 +53,7 @@ where = src [options.extras_require] dev = ipython[all]>=3.1 doc = sphinx>=2.1; sphinx-gallery>=0.4; doc8; m2r; netCDF4 -examples = cartopy>=0.13.1; matplotlib>=2.2.0; pyproj>=1.9.4,!=2.0.0 +examples = cartopy>=0.15.0; matplotlib>=2.2.0; pyproj>=1.9.4,!=2.0.0 test = pytest>=2.4; pytest-mpl; pytest-flake8; cartopy>=0.16.0; flake8>3.2.0; flake8-builtins!=1.4.0; flake8-comprehensions; flake8-copyright; flake8-docstrings; flake8-import-order; flake8-mutable; flake8-pep3101; flake8-print; flake8-quotes; flake8-rst-docstrings; pep8-naming; netCDF4; pyproj>=1.9.4,!=2.0.0 [build_sphinx] diff --git a/src/metpy/plots/station_plot.py b/src/metpy/plots/station_plot.py index f51a97b9fde..4ede85c1888 100644 --- a/src/metpy/plots/station_plot.py +++ b/src/metpy/plots/station_plot.py @@ -5,7 +5,6 @@ from enum import Enum -import matplotlib import numpy as np from .wx_symbols import (current_weather, high_clouds, low_clouds, mid_clouds, @@ -276,20 +275,7 @@ def plot_barb(self, u, v, **kwargs): if self.barbs: self.barbs.remove() - # Handle transforming our center points. CartoPy doesn't like 1D barbs - # TODO: This can be removed for cartopy > 0.14.3 - if hasattr(self.ax, 'projection') and 'transform' in kwargs: - trans = kwargs['transform'] - try: - kwargs['transform'] = trans._as_mpl_transform(self.ax) - except AttributeError: - pass - u, v = self.ax.projection.transform_vectors(trans, self.x, self.y, u, v) - - # Since we've re-implemented CartoPy's barbs, we need to skip calling it here - self.barbs = matplotlib.axes.Axes.barbs(self.ax, self.x, self.y, u, v, **defaults) - else: - self.barbs = self.ax.barbs(self.x, self.y, u, v, **defaults) + self.barbs = self.ax.barbs(self.x, self.y, u, v, **defaults) def plot_arrow(self, u, v, **kwargs): r"""At the center of the station model plot wind arrows. @@ -328,21 +314,7 @@ def plot_arrow(self, u, v, **kwargs): if self.arrows: self.arrows.remove() - # Handle transforming our center points. CartoPy doesn't like 1D arrows - # TODO: This can be removed for cartopy > 0.14.3 - if hasattr(self.ax, 'projection') and 'transform' in kwargs: - trans = kwargs['transform'] - try: - kwargs['transform'] = trans._as_mpl_transform(self.ax) - except AttributeError: - pass - u, v = self.ax.projection.transform_vectors(trans, self.x, self.y, u, v) - - # Since we've re-implemented CartoPy's arrows, we need to skip calling it here - self.arrows = matplotlib.axes.Axes.quiver(self.ax, self.x, self.y, u, v, - **defaults) - else: - self.arrows = self.ax.quiver(self.x, self.y, u, v, **defaults) + self.arrows = self.ax.quiver(self.x, self.y, u, v, **defaults) @staticmethod def _plotting_units(u, v, plotting_units):