cedadev / jasmin_scivm

9 stars 0 forks source link

pyproj missing #184

Closed alaniwi closed 5 years ago

alaniwi commented 5 years ago

This happens:

>>> import mpl_toolkits.basemap.pyproj as pyproj
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pyproj

In python27-basemap-1.0.7-1.ceda.el6.x86_64 it is present:

$ rpm -ql python27-basemap | grep pyproj
/usr/lib/python2.7/site-packages/mpl_toolkits/basemap/pyproj.py
/usr/lib/python2.7/site-packages/mpl_toolkits/basemap/pyproj.pyc
/usr/lib/python2.7/site-packages/mpl_toolkits/basemap/pyproj.pyo

In python27-basemap-1.1.0-1.ceda.el6.x86_64 it is not (above command gives no output).

Seems it has been removed from basemap:

$ git clone https://github.com/matplotlib/basemap.git

$ cd basemap

$ git checkout v1.1.0

$ find . -name 'pyproj.py'
[nothing found]

$ git checkout v1.0.7rel

$ find . -name 'pyproj.py'
./lib/mpl_toolkits/basemap/pyproj.py

One of the commits is revealing:

$ git log
[...]
    remove unused c code. This is pyproj which is now an external dependency
[...]

There is https://pypi.org/project/pyproj/

Try building pyproj separately and adding to the JAP.

alaniwi commented 5 years ago

pyproj is already built and installed. import pyproj works.

alaniwi commented 5 years ago

Found test code which uses the old incantation:

from mpl_toolkits.basemap import Basemap
from mpl_toolkits.basemap import pyproj

ulm = [-8895604.1573329996, 3335851.5589999999]  #upper left, meters
lrm = [-7783653.6376670003, 2223901.0393329998]  #lower right, meters

sinu = pyproj.Proj(proj='sinu', lon_0=0.0, x_0=0.0, y_0=0.0)
m = Basemap(projection='sinu', resolution=None, lon_0=0.0)

print "ULM: " + str(ulm)
print "Proj: " + str(sinu(ulm[0], ulm[1], inverse=True))
print "Basemap: " + str(m(ulm[0], ulm[1], inverse=True))

Running this on a system running the previous version of JAP and replacing the import with import pyproj gives identical results. The same is obtained on a system with the latest JAP.

Will advise users to replace import mpl_toolkits.basemap.pyproj as pyproj with import pyproj in their code.