@@ -3901,6 +3901,12 @@ def drawlsmask(self,land_color="0.8",ocean_color="w",lsmask=None,
3901
3901
# look for axes instance (as keyword, an instance variable
3902
3902
# or from plt.gca().
3903
3903
ax = kwargs .pop ('ax' , None ) or self ._check_ax ()
3904
+ # Clear saved lsmask if new lsmask is passed
3905
+ if lsmask is not None or lsmask_lons is not None \
3906
+ or lsmask_lats is not None :
3907
+ # Make sure passed lsmask is not the same as cached mask
3908
+ if lsmask is not self .lsmask :
3909
+ self .lsmask = None
3904
3910
# if lsmask,lsmask_lons,lsmask_lats keywords not given,
3905
3911
# read default land-sea mask in from file.
3906
3912
if lsmask is None or lsmask_lons is None or lsmask_lats is None :
@@ -3910,28 +3916,28 @@ def drawlsmask(self,land_color="0.8",ocean_color="w",lsmask=None,
3910
3916
# read in land/sea mask.
3911
3917
lsmask_lons , lsmask_lats , lsmask = \
3912
3918
_readlsmask (lakes = lakes ,resolution = resolution ,grid = grid )
3913
- # instance variable lsmask is set on first invocation,
3914
- # it contains the land-sea mask interpolated to the native
3915
- # projection grid. Further calls to drawlsmask will not
3916
- # redo the interpolation (unless a new land-sea mask is passed
3917
- # in via the lsmask, lsmask_lons, lsmask_lats keywords).
3918
-
3919
- # is it a cylindrical projection whose limits lie
3920
- # outside the limits of the image?
3921
- cylproj = self .projection in _cylproj and \
3922
- (self .urcrnrlon > lsmask_lons [- 1 ] or \
3923
- self .llcrnrlon < lsmask_lons [0 ])
3924
- if cylproj :
3925
- # stack grids side-by-side (in longitiudinal direction), so
3926
- # any range of longitudes may be plotted on a world map.
3927
- # in versions of NumPy later than 1.10.0, concatenate will
3928
- # not stack these arrays as expected. If axis 1 is outside
3929
- # the dimensions of the array, concatenate will now raise
3930
- # an IndexError. Using hstack instead.
3931
- lsmask_lons = \
3932
- np .hstack ((lsmask_lons ,lsmask_lons [1 :] + 360 ))
3933
- lsmask = \
3934
- np .hstack ((lsmask ,lsmask [:,1 :]))
3919
+ # instance variable lsmask is set on first invocation,
3920
+ # it contains the land-sea mask interpolated to the native
3921
+ # projection grid. Further calls to drawlsmask will not
3922
+ # redo the interpolation (unless a new land-sea mask is passed
3923
+ # in via the lsmask, lsmask_lons, lsmask_lats keywords).
3924
+
3925
+ # is it a cylindrical projection whose limits lie
3926
+ # outside the limits of the image?
3927
+ cylproj = self .projection in _cylproj and \
3928
+ (self .urcrnrlon > lsmask_lons [- 1 ] or \
3929
+ self .llcrnrlon < lsmask_lons [0 ])
3930
+ if cylproj :
3931
+ # stack grids side-by-side (in longitiudinal direction), so
3932
+ # any range of longitudes may be plotted on a world map.
3933
+ # in versions of NumPy later than 1.10.0, concatenate will
3934
+ # not stack these arrays as expected. If axis 1 is outside
3935
+ # the dimensions of the array, concatenate will now raise
3936
+ # an IndexError. Using hstack instead.
3937
+ lsmask_lons = \
3938
+ np .hstack ((lsmask_lons ,lsmask_lons [1 :] + 360 ))
3939
+ lsmask = \
3940
+ np .hstack ((lsmask ,lsmask [:,1 :]))
3935
3941
else :
3936
3942
if lakes : lsmask = np .where (lsmask == 2 ,np .array (0 ,np .uint8 ),lsmask )
3937
3943
0 commit comments