From 57e75faae7b2ac68a2614674fe6d64b5a5a9ea59 Mon Sep 17 00:00:00 2001 From: AS <aaron.spring@mpimet.mpg.de> Date: Mon, 15 Jun 2020 12:05:59 +0200 Subject: [PATCH] bugfix --- pymistral/plot.py | 13 +++++++++++-- pymistral/tests/test_plot.py | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pymistral/plot.py b/pymistral/plot.py index e874392..8b90ea1 100644 --- a/pymistral/plot.py +++ b/pymistral/plot.py @@ -137,8 +137,8 @@ class CartopyMap(object): print( 'use stereo maps and facet plots by:', ' fig,ax=plt.subplots(subplot_kw=', - f'{"projection":ccrs.NorthPolarStereo()}\n', - 'd.isel(time=0).plot_map(proj=proj,ax=ax)' + '{"projection":ccrs.NorthPolarStereo()}\n', + 'd.isel(time=0).plot_map(proj=proj,ax=ax)', ) if single_plot: axm = getattr(xda.plot, plot_type)( @@ -159,6 +159,15 @@ class CartopyMap(object): else: if round: ax.set_boundary(circle, transform=ax.transAxes) + max_lat = 30 + if isinstance(proj, ccrs.NorthPolarStereo): + ax.set_extent( + [-180, 180, max_lat, 90], crs=ccrs.PlateCarree() + ) + elif isinstance(proj, ccrs.SouthPolarStereo): + ax.set_extent( + [-180, 180, -90, -max_lat], crs=ccrs.PlateCarree() + ) axm = getattr(xda.plot, plot_type)( lon, lat, ax=ax, transform=ccrs.PlateCarree(), **kwargs ) diff --git a/pymistral/tests/test_plot.py b/pymistral/tests/test_plot.py index 89ee805..2e94ca2 100644 --- a/pymistral/tests/test_plot.py +++ b/pymistral/tests/test_plot.py @@ -60,7 +60,8 @@ def test_plot_map_projstr(da, projstr): pytest.lazy_fixture('air_temperature_da'), ], ) -@pytest.mark.parametrize('projstr', ['NorthPolarStereo']) +@pytest.mark.parametrize('projstr', ['NorthPolarStereo','SouthPolarStereo','Stereographic']) def test_plot_map_stereo(da, projstr): - fig, ax = plt.subplots(subplot_kw={'projection': ccrs.NorthPolarStereo()}) + proj = eval(f'ccrs.{projstr}()') + fig, ax = plt.subplots(subplot_kw={'projection': proj}) da.isel(time=0).plot_map(proj=projstr, ax=ax) -- GitLab