I have a quick hack of basemap to allow it to draw a great circle passing the
map borders. It should work for the cylinder project (i.e., no projection)
and a map with longitude -180 to 180.
Instruction:
- Edit the file:
PythonInstallDirectory/lib/python2.4/site-packages/matplotlib/toolkits/basemap/basemap.py
- Insert the following line
x,y = fixlon(x,y)
before this line
self.plot(x,y,**kwargs)
- Add the following to the top of the file:
import Numeric as Num
import MA
def fixlon(lon,lat):
if type(lon) == type([1,]) or type(lon) == type((1,)):
lon0 = Num.array(lon)
lat0 = Num.array(lat)
else:
lon0 = lon
lat0 = lat
···
#
n = len(lon0)
temp1 = lon0[1:] - lon0[:-1]
temp2 = temp1>0
np = Num.sum(temp2)
#
isIncrease = None
if np<=2:
isIncrease = 1
elif n-np<=2:
isIncrease = 0
else:
print 'n, np = ', n, np
return
#
if not isIncrease:
temp2 = Num.logical_not(temp2)
temp3 = Num.nonzero(temp2)
i0 = Num.argmax( Num.take(Num.fabs(temp1), temp3) )
i = temp3[i0]
print 'n,i=', n, i
#
lon1 =
MA.array(Num.zeros((n+1,)),mask=Num.zeros((n+1,))).astype(lon0.typecode())
lat1 =
MA.array(Num.zeros((n+1,)),mask=Num.zeros((n+1,))).astype(lon0.typecode())
lon1[:i+1] = lon0[:i+1]
lat1[:i+1] = lat0[:i+1]
lon1[i+2:] = lon0[i+1:]
lat1[i+2:] = lat0[i+1:]
lon1.mask()[i+1] = 1
lat1.mask()[i+1] = 1
#
return lon1, lat1