@@ -2924,8 +2924,8 @@ def drawgreatcircle(self,lon1,lat1,lon2,lat2,del_s=100.,**kwargs):
29242924
29252925 # create new vertices with a nan inbetween and set those as the path's vertices
29262926 verts = np .concatenate (
2927- [p .vertices [:cut_point , :],
2928- [[np .nan , np .nan ]],
2927+ [p .vertices [:cut_point , :],
2928+ [[np .nan , np .nan ]],
29292929 p .vertices [cut_point + 1 :, :]]
29302930 )
29312931 p .codes = None
@@ -4087,7 +4087,7 @@ def warpimage(self,image="bluemarble",scale=None,**kwargs):
40874087 from PIL import Image
40884088 except ImportError :
40894089 try :
4090- import Image
4090+ import Image
40914091 except ImportError :
40924092 raise ImportError ('warpimage method requires PIL (http://www.pythonware.com/products/pil)' )
40934093
@@ -5087,11 +5087,13 @@ def shiftgrid(lon0,datain,lonsin,start=True,cyclic=360.0):
50875087 dataout [...,i0_shift :] = datain [...,start_idx :i0 + start_idx ]
50885088 return dataout ,lonsout
50895089
5090- def addcyclic (arrin ,lonsin ):
5090+ def addcyclic (arrin ,lonsin , cyclic_length = 360 ):
50915091 """
50925092 ``arrout, lonsout = addcyclic(arrin, lonsin)``
50935093 adds cyclic (wraparound) point in longitude to ``arrin`` and ``lonsin``,
50945094 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``.
50955097 """
50965098 nlons = arrin .shape [- 1 ]
50975099 newshape = list (arrin .shape )
@@ -5107,8 +5109,10 @@ def addcyclic(arrin,lonsin):
51075109 else :
51085110 lonsout = np .zeros (nlons + 1 ,lonsin .dtype )
51095111 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 ])
51125116
51135117def _choosecorners (width ,height ,** kwargs ):
51145118 """
0 commit comments