PyROMS bug

General scientific issues regarding ROMS

Moderators: arango, robertson

Post Reply
Message
Author
User avatar
m.hadfield
Posts: 521
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

PyROMS bug

#1 Unread post by m.hadfield »

Code: Select all

Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 17:14:51)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyroms_toolbox
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hadfield/.local/lib/python3.6/site-packages/pyroms_toolbox/__init__.py", line 52, in <module>
    from .TS_diagram import TS_diagram
  File "/home/hadfield/.local/lib/python3.6/site-packages/pyroms_toolbox/TS_diagram.py", line 8, in <module>
    def TS_diagram(temp, salt, depth=None, dens_lev=None, marker_size=2, fmt='%2.2f', pal=cm.spectral, \
AttributeError: module 'matplotlib.cm' has no attribute 'spectral'
>>>
The TS_diagram function in pyroms_toolbox/TS_diagram.py sets a default palette of cm.spectral. This should be cm.Spectral

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: PyROMS bug

#2 Unread post by kate »

Thank you, fixed.

Say, do you know about pull requests?

User avatar
m.hadfield
Posts: 521
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

Re: PyROMS bug

#3 Unread post by m.hadfield »

Sure do! I submitted the one and only pull request I've ever prepared to you a few weeks ago.

User avatar
m.hadfield
Posts: 521
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

Re: PyROMS bug

#4 Unread post by m.hadfield »

Another PyROMS problem; might as well use the same thread...

I have more-or-less successfully (?) built and installed PyROMS with the following commands

Code: Select all

# The system is CentOS 7 with Miniconda (single-user install).
# Python 3.6, numpy, netcdf, etc are installed in a custom environment called "python36"
# The pyroms code at https://github.com/hadfieldnz/pyroms-mgh has been
# cloned into ~/Python/python-mgh

# Activate the Conda python36 environment and set up some handy shell environment variables
conda activate python36
export PREFIX=/home/hadfield/.local
export SITE_PACKAGES=${PREFIX}/lib/python3.6/site-packages
export PYTHON36=/home/hadfield/miniconda3/envs/python36

# Build and install bathy_smoother
cd ~/Python/pyroms-mgh/bathy_smoother
python setup.py build
python setup.py install --prefix=${PREFIX}

# Build and install pyroms_toolbox
cd ~/Python/pyroms-mgh/pyroms_toolbox
python setup.py build
python setup.py install --prefix=${PREFIX}

# Build and install pyroms
cd ~/Python/pyroms-mgh/pyroms
python setup.py build
python setup.py install --prefix=${PREFIX}

# Build and install nn
cd ~/Python/pyroms-mgh/pyroms/external/nn
./configure --prefix=${PREFIX}
make install

# Build and install pyroms_csa
cd ~/Python/pyroms-mgh/pyroms/external/csa
./configure --prefix=${PREFIX}
make install

# Build and install gridutils
cd ~/Python/pyroms-mgh/pyroms/external/gridutils
./configure CPPFLAGS=-I${PREFIX}/include LDFLAGS=-L${PREFIX}/lib CFLAGS=-I${PREFIX}/include --prefix=${PREFIX}
make install

# Build and install gridgen
cd ~/Python/pyroms-mgh/pyroms/external/gridgen
export SHLIBS=-L${PREFIX}/lib
./configure CPPFLAGS=-I${PREFIX}/include LDFLAGS=-L${PREFIX}/lib CFLAGS=-I${PREFIX}/include --prefix=${PREFIX}
make
make lib
make shlib
make install

# Build and install scrip. The netCDF configuration is passed explicity via command-line
# variables because nf-config is broken on CentOS 7. The "-j 1" may or may not be needed 
# to work around broken dependencies in the make file.
cd ~/Python/pyroms-mgh/pyroms/external/scrip/source
make -j 1 PREFIX=${PREFIX} LIBDIR=${PYTHON36}/lib INCDIR=${PYTHON36}/include LIB="-lnetcdff -lnetcdf" all f2py
make -j 1 PREFIX=${PREFIX} LIBDIR=${PYTHON36}/lib INCDIR=${PYTHON36}/include LIB="-lnetcdff -lnetcdf" install

# Copy dynamic libraries to the site-packages directory. They are copied one at a time
# so I can keep track of which ones have been copied.
cd ~/Python/pyroms-mgh/
cp -v  ./pyroms/external/scrip/source/scrip.cpython-36m-x86_64-linux-gnu.so ${SITE_PACKAGES}
cp -v ./pyroms/build/lib.linux-x86_64-3.6/pyroms/_iso.cpython-36m-x86_64-linux-gnu.so ${SITE_PACKAGES}
cp -v ./pyroms/build/lib.linux-x86_64-3.6/pyroms/_obs_interp.cpython-36m-x86_64-linux-gnu.so ${SITE_PACKAGES}
cp -v ./pyroms/build/lib.linux-x86_64-3.6/pyroms/_interp.cpython-36m-x86_64-linux-gnu.so ${SITE_PACKAGES}
cp -v ./pyroms/build/lib.linux-x86_64-3.6/pyroms/_remapping.cpython-36m-x86_64-linux-gnu.so ${SITE_PACKAGES}
cp -v ./pyroms_toolbox/build/lib.linux-x86_64-3.6/pyroms_toolbox/_average.cpython-36m-x86_64-linux-gnu.so ${SITE_PACKAGES}
cp -v ./pyroms/build/lib.linux-x86_64-3.6/pyroms/_remapping_fast.cpython-36m-x86_64-linux-gnu.so ${SITE_PACKAGES}
cp -v ./pyroms_toolbox/build/lib.linux-x86_64-3.6/pyroms_toolbox/creep.cpython-36m-x86_64-linux-gnu.so ${SITE_PACKAGES}
cp -v ./pyroms/build/lib.linux-x86_64-3.6/pyroms/_remapping_fast_weighted.cpython-36m-x86_64-linux-gnu.so ${SITE_PACKAGES}
cp -v ./bathy_smoother/build/lib.linux-x86_64-3.6/bathy_smoother/lpsolve55.cpython-36m-x86_64-linux-gnu.so ${SITE_PACKAGES}
When I start Python and import the dynamic-library modules, all goes well until I get to lpsolve55.

Code: Select all

$ conda activate python36
$ python
Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 17:14:51)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import scrip
>>> import _iso
>>> import _obs_interp
>>> import _interp
>>> import _remapping
>>> import _average
>>> import _remapping_fast
>>> import creep
>>> import _remapping_fast_weighted
>>> import lpsolve55
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define module export function (PyInit_lpsolve55)
>>>
I will start looking into the problem shortly, but figured I might as well report it to the forum first.

PS: I think bathy_smoother works OK, but with reduced functionality, without the LP solver.

nilodna
Posts: 6
Joined: Thu May 02, 2013 6:38 pm
Location: Oceanographic Institute from University of Sao Pau

Re: PyROMS bug

#5 Unread post by nilodna »

Dear m.hadfield,

Has been a while since you post and I don't know if the problem was solved. But I installed lpsolve55 using conda and it worked for me (using python 3.7.2 with miniconda3).

You can do the same in your environment with:

Code: Select all

conda install -c conda-forge lpsolve55
And next reinstall bathy_smoother, following the same steps you already posted.

Hope it works.

Cheers

User avatar
m.hadfield
Posts: 521
Joined: Tue Jul 01, 2003 4:12 am
Location: NIWA

Re: PyROMS bug

#6 Unread post by m.hadfield »

Thank you. I did not know that lpsolve55 is available via Conda.

Post Reply