Skip to content

Commit a3adb91

Browse files
committed
Add future deprecation warning for Basemap
1 parent e28ef57 commit a3adb91

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

pysteps/visualization/basemaps.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,25 @@
1414
from matplotlib import gridspec
1515
import matplotlib.pylab as plt
1616
import numpy as np
17+
import warnings
1718
from pysteps.exceptions import MissingOptionalDependency
1819

1920
try:
2021
from mpl_toolkits.basemap import Basemap
22+
2123
basemap_imported = True
2224
except ImportError:
2325
basemap_imported = False
2426
try:
2527
import cartopy.crs as ccrs
2628
import cartopy.feature as cfeature
29+
2730
cartopy_imported = True
2831
except ImportError:
2932
cartopy_imported = False
3033
try:
3134
import pyproj
35+
3236
pyproj_imported = True
3337
except ImportError:
3438
pyproj_imported = False
@@ -95,15 +99,15 @@ def plot_geography(map, proj4str, extent, shape=None, lw=0.5,
9599
+ " 'basemap' or 'cartopy'" % map)
96100
if map == "basemap" and not basemap_imported:
97101
raise MissingOptionalDependency(
98-
"map='basemap' option passed to plot_geography function"
102+
"map='basemap' option passed to plot_geography function "
99103
"but the basemap package is not installed")
100104
if map == "cartopy" and not cartopy_imported:
101105
raise MissingOptionalDependency(
102-
"map='cartopy' option passed to plot_geography function"
106+
"map='cartopy' option passed to plot_geography function "
103107
"but the cartopy package is not installed")
104108
if map is not None and not pyproj_imported:
105109
raise MissingOptionalDependency(
106-
"map!=None option passed to plot_geography function"
110+
"map!=None option passed to plot_geography function "
107111
"but the pyproj package is not installed")
108112

109113
if map == "basemap":
@@ -181,9 +185,13 @@ def plot_map_basemap(bm_params, drawlonlatlines=False,
181185
"""
182186
if not basemap_imported:
183187
raise MissingOptionalDependency(
184-
"map='basemap' option passed to plot_map_basemap function"
188+
"map='basemap' option passed to plot_map_basemap function "
185189
"but the basemap package is not installed")
186190

191+
warnings.warn(
192+
"Basemap will be deprecated in a future release of pysteps, use Cartopy instead",
193+
PendingDeprecationWarning)
194+
187195
ax = Basemap(**bm_params)
188196

189197
if coastlinecolor is not None:
@@ -238,7 +246,7 @@ def plot_map_cartopy(crs, extent, scale, drawlonlatlines=False,
238246
"""
239247
if not cartopy_imported:
240248
raise MissingOptionalDependency(
241-
"map='cartopy' option passed to plot_map_cartopy function"
249+
"map='cartopy' option passed to plot_map_cartopy function "
242250
"but the cartopy package is not installed")
243251

244252
if isinstance(subplot, gridspec.SubplotSpec):

0 commit comments

Comments
 (0)