python addcyclic routine
1 def addcyclic(arrin,lonsin):
2 """
3 ``arrout, lonsout = addcyclic(arrin, lonsin)``
4 adds cyclic (wraparound) point in longitude to ``arrin`` and ``lonsin``.
5 """
6 nlats = arrin.shape[0]
7 nlons = arrin.shape[1]
8 if ma.isMA(arrin):
9 arrout = ma.zeros((nlats,nlons+1),arrin.dtype)
10 else:
11 arrout = np.zeros((nlats,nlons+1),arrin.dtype)
12 arrout[:,0:nlons] = arrin[:,:]
13 arrout[:,nlons] = arrin[:,0]
14 if ma.isMA(lonsin):
15 lonsout = ma.zeros(nlons+1,lonsin.dtype)
16 else:
17 lonsout = np.zeros(nlons+1,lonsin.dtype)
18 lonsout[0:nlons] = lonsin[:]
19 lonsout[nlons] = lonsin[-1] + lonsin[1]-lonsin[0]
20 return arrout,lonsout