Skip to content

Commit 928421d

Browse files
committed
refactor masking of the shifted longitudes and data to a single place, since it is the same for 1d and 2d cases
1 parent 9a60432 commit 928421d

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4811,13 +4811,7 @@ def shiftdata(self,lonsin,datain=None,lon_0=None):
48114811
datain_save[:,1:] = datain
48124812
datain_save[:,0] = datain[:,-1]
48134813
datain = datain_save
4814-
# mask points outside
4815-
# map region so they don't wrap back in the domain.
4816-
mask = np.logical_or(lonsin<lon_0-180,lonsin>lon_0+180)
4817-
lonsin = np.where(mask,1.e30,lonsin)
4818-
if datain is not None and mask.any():
4819-
# superimpose on existing mask
4820-
datain = ma.masked_where(mask, datain)
4814+
48214815
# 1-d data.
48224816
elif lonsin.ndim == 1:
48234817
nlons = len(lonsin)
@@ -4856,12 +4850,15 @@ def shiftdata(self,lonsin,datain=None,lon_0=None):
48564850
datain_save[1:] = datain
48574851
datain_save[0] = datain[-1]
48584852
datain = datain_save
4859-
# mask points outside
4860-
# map region so they don't wrap back in the domain.
4861-
mask = np.logical_or(lonsin<lon_0-180,lonsin>lon_0+180)
4862-
lonsin = np.where(mask,1.e30,lonsin)
4863-
if datain is not None and mask.any():
4864-
datain = ma.masked_where(mask, datain)
4853+
4854+
# mask points outside
4855+
# map region so they don't wrap back in the domain.
4856+
mask = np.logical_or(lonsin<lon_0-180,lonsin>lon_0+180)
4857+
lonsin = np.where(mask,1.e30,lonsin)
4858+
if datain is not None and mask.any():
4859+
datain = ma.masked_where(mask, datain)
4860+
4861+
48654862
if datain is not None:
48664863
return lonsin, datain
48674864
else:

0 commit comments

Comments
 (0)