Skip to content

Commit 650f14d

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 6c6c398 commit 650f14d

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
@@ -4810,13 +4810,7 @@ def shiftdata(self,lonsin,datain=None,lon_0=None):
48104810
datain_save[:,1:] = datain
48114811
datain_save[:,0] = datain[:,-1]
48124812
datain = datain_save
4813-
# mask points outside
4814-
# map region so they don't wrap back in the domain.
4815-
mask = np.logical_or(lonsin<lon_0-180,lonsin>lon_0+180)
4816-
lonsin = np.where(mask,1.e30,lonsin)
4817-
if datain is not None and mask.any():
4818-
# superimpose on existing mask
4819-
datain = ma.masked_where(mask, datain)
4813+
48204814
# 1-d data.
48214815
elif lonsin.ndim == 1:
48224816
nlons = len(lonsin)
@@ -4855,12 +4849,15 @@ def shiftdata(self,lonsin,datain=None,lon_0=None):
48554849
datain_save[1:] = datain
48564850
datain_save[0] = datain[-1]
48574851
datain = datain_save
4858-
# mask points outside
4859-
# map region so they don't wrap back in the domain.
4860-
mask = np.logical_or(lonsin<lon_0-180,lonsin>lon_0+180)
4861-
lonsin = np.where(mask,1.e30,lonsin)
4862-
if datain is not None and mask.any():
4863-
datain = ma.masked_where(mask, datain)
4852+
4853+
# mask points outside
4854+
# map region so they don't wrap back in the domain.
4855+
mask = np.logical_or(lonsin<lon_0-180,lonsin>lon_0+180)
4856+
lonsin = np.where(mask,1.e30,lonsin)
4857+
if datain is not None and mask.any():
4858+
datain = ma.masked_where(mask, datain)
4859+
4860+
48644861
if datain is not None:
48654862
return lonsin, datain
48664863
else:

0 commit comments

Comments
 (0)