@@ -2924,8 +2924,8 @@ def drawgreatcircle(self,lon1,lat1,lon2,lat2,del_s=100.,**kwargs):
2924
2924
2925
2925
# create new vertices with a nan inbetween and set those as the path's vertices
2926
2926
verts = np .concatenate (
2927
- [p .vertices [:cut_point , :],
2928
- [[np .nan , np .nan ]],
2927
+ [p .vertices [:cut_point , :],
2928
+ [[np .nan , np .nan ]],
2929
2929
p .vertices [cut_point + 1 :, :]]
2930
2930
)
2931
2931
p .codes = None
@@ -4087,7 +4087,7 @@ def warpimage(self,image="bluemarble",scale=None,**kwargs):
4087
4087
from PIL import Image
4088
4088
except ImportError :
4089
4089
try :
4090
- import Image
4090
+ import Image
4091
4091
except ImportError :
4092
4092
raise ImportError ('warpimage method requires PIL (http://www.pythonware.com/products/pil)' )
4093
4093
@@ -5087,11 +5087,13 @@ def shiftgrid(lon0,datain,lonsin,start=True,cyclic=360.0):
5087
5087
dataout [...,i0_shift :] = datain [...,start_idx :i0 + start_idx ]
5088
5088
return dataout ,lonsout
5089
5089
5090
- def addcyclic (arrin ,lonsin ):
5090
+ def addcyclic (arrin ,lonsin , cyclic_length = 360 ):
5091
5091
"""
5092
5092
``arrout, lonsout = addcyclic(arrin, lonsin)``
5093
5093
adds cyclic (wraparound) point in longitude to ``arrin`` and ``lonsin``,
5094
5094
assumes longitude is the right-most dimension of ``arrin``.
5095
+ If length of cyclic dimension is not 360 (degrees), set with kwarg
5096
+ ``cyclic_length``.
5095
5097
"""
5096
5098
nlons = arrin .shape [- 1 ]
5097
5099
newshape = list (arrin .shape )
@@ -5107,8 +5109,10 @@ def addcyclic(arrin,lonsin):
5107
5109
else :
5108
5110
lonsout = np .zeros (nlons + 1 ,lonsin .dtype )
5109
5111
lonsout [0 :nlons ] = lonsin [:]
5110
- lonsout [nlons ] = lonsin [- 1 ] + lonsin [1 ]- lonsin [0 ]
5111
- return arrout ,lonsout
5112
+ # this assumes a regular grid (in longitude)
5113
+ #lonsout[nlons] = lonsin[-1] + lonsin[1]-lonsin[0]
5114
+ # the version below is valid for irregular grids.
5115
+ lonsout [nlons ] = lonsin [- 1 ] + cyclic_length % (lonsin [- 1 ]- lonsin [0 ])
5112
5116
5113
5117
def _choosecorners (width ,height ,** kwargs ):
5114
5118
"""
0 commit comments