Skip to content

Commit 60e417c

Browse files
author
Jeff Whitaker
committed
Merge pull request #99 from ajdawson/shiftgrid-ndim
Extended shiftgrid to arbitrary dimensions.
2 parents 66021f2 + fe74357 commit 60e417c

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4919,7 +4919,8 @@ def shiftgrid(lon0,datain,lonsin,start=True,cyclic=360.0):
49194919
lon0 starting longitude for shifted grid
49204920
(ending longitude if start=False). lon0 must be on
49214921
input grid (within the range of lonsin).
4922-
datain original data.
4922+
datain original data with longitude the right-most
4923+
dimension.
49234924
lonsin original longitudes.
49244925
============== ====================================================
49254926
@@ -4958,20 +4959,12 @@ def shiftgrid(lon0,datain,lonsin,start=True,cyclic=360.0):
49584959
lonsout[0:i0_shift] = lonsin[i0:]
49594960
else:
49604961
lonsout[0:i0_shift] = lonsin[i0:]-cyclic
4961-
if datain.ndim == 2:
4962-
dataout[:,0:i0_shift] = datain[:,i0:]
4963-
elif datain.ndim == 1:
4964-
dataout[0:i0_shift] = datain[i0:]
4965-
else:
4966-
raise ValueError('data must be 1d or 2d with longitude as 2nd dim')
4962+
dataout[...,0:i0_shift] = datain[...,i0:]
49674963
if start:
49684964
lonsout[i0_shift:] = lonsin[start_idx:i0+start_idx]+cyclic
49694965
else:
49704966
lonsout[i0_shift:] = lonsin[start_idx:i0+start_idx]
4971-
if datain.ndim == 2:
4972-
dataout[:,i0_shift:] = datain[:,start_idx:i0+start_idx]
4973-
elif datain.ndim == 1:
4974-
dataout[i0_shift:] = datain[start_idx:i0+start_idx]
4967+
dataout[...,i0_shift:] = datain[...,start_idx:i0+start_idx]
49754968
return dataout,lonsout
49764969

49774970
def addcyclic(arrin,lonsin):

0 commit comments

Comments
 (0)