Closed
Description
I know we have a lot of issues already, but this one is intriguing and maybe gives an opportunity to learn more about cython...
Basemap works fine in the following situations (below lon2d and lat2d are 2D numpy arrays of latitudes and longitudes):
a)
xx, yy = basemap(lons2d.T, lats2d.T)
b)
xx, yy = basemap(lons2d.flatten(), lats2d.flatten())
c) Looping through each point of the arrays and projecting works fine as well...
BUT
when I try to reproject the unchanged arrays
xx, yy = basemap(lons2d, lats2d)
I get the exception below:
In [4]: xx, yy = bmp(lons, lats)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-4-cd4fecf35ebb> in <module>()
----> 1 xx, yy = bmp(lons, lats)
/RESCUE/skynet3_rech1/huziy/python_virtualenvs/py3.4/lib/python3.4/site-packages/mpl_toolkits/basemap/__init__.py in __call__(self, x, y, inverse)
1146 except TypeError:
1147 y = [_dg2rad*yy for yy in y]
-> 1148 xout,yout = self.projtran(x,y,inverse=inverse)
1149 if self.celestial and inverse:
1150 try:
/RESCUE/skynet3_rech1/huziy/python_virtualenvs/py3.4/lib/python3.4/site-packages/mpl_toolkits/basemap/proj.py in __call__(self, *args, **kw)
284 outxy = self._proj4(xy, inverse=inverse)
285 else:
--> 286 outx,outy = self._proj4(x, y, inverse=inverse)
287 if inverse:
288 if self.projection in ['merc','mill','gall']:
/RESCUE/skynet3_rech1/huziy/python_virtualenvs/py3.4/lib/python3.4/site-packages/mpl_toolkits/basemap/pyproj.py in __call__(self, *args, **kw)
386 _proj.Proj._inv(self, inx, iny, radians=radians, errcheck=errcheck)
387 else:
--> 388 _proj.Proj._fwd(self, inx, iny, radians=radians, errcheck=errcheck)
389 # if inputs were lists, tuples or floats, convert back.
390 outx = _convertback(xisfloat,xislist,xistuple,inx)
_proj.pyx in _proj.Proj._fwd (src/_proj.c:1571)()
RuntimeError:
I am using Python 3.4.3, Basemap 1.0.7
I've pickled the list [lons, lats, basemap] and attached the file here if anoyone wants to try to reproduce (you can download it from here: http://scaweb.sca.uqam.ca/~huziy/lon_lat_bmp_problem.bin).
and then use it as
import pickle
lons, lats, bmp = pickle.load(open("lon_lat_bmp_problem.bin","rb"))
xx, yy = bmp(lons, lats) # <-- should throw an exception
Cheers
Metadata
Metadata
Assignees
Labels
No labels