hetland / octant

Ocean C-grid model setup and analysis tools, for the numerical mariner.
Other
33 stars 25 forks source link

importing octant.csa #4

Open fagundesmo opened 9 years ago

fagundesmo commented 9 years ago

Dear Dr. Hetland,

I am new octant user and I've just installed octant successfully. However, I have been facing a problem when importing octant.csa, it keeps me showing this error:

OSError Traceback (most recent call last)

in () ----> 1 import octant.csa /usr/local/lib/python2.7/dist-packages/octant/csa.py in () 7 import octant 8 ----> 9 class CSA(object): 10 '''cubic spline approximation for re-gridding 2D data sets 11 /usr/local/lib/python2.7/dist-packages/octant/csa.py in CSA() 59 ''' 60 ---> 61 _csa = np.ctypeslib.load_library('_csa', '/usr/local/lib/python2.7/dis-packages/octant') 62 63 /usr/lib/python2.7/dist-packages/numpy/ctypeslib.pyc in load_library(libname, loader_path) 134 raise 135 ## if no successful return in the libname_ext loop: --> 136 raise OSError("no file with expected extension") 137 138 ctypes_load_library = deprecate(load_library, 'ctypes_load_library', OSError: no file with expected extension Even though, all libs have been installed in their default path (/usr/local/) and csa's path had been changed before I compiled octant. Would you have any idea what it's going on? Cheers, Matheus
garciaga commented 8 years ago

I just ran into the same problem. I know this is an old issue but I will write my workaround here for future reference.

To fix it I had to download csa from sakov's github and install it. This generates a libcsa.so which I copied to:

/path/to/my/python/installation/lib/python2.7/site-packages/octant/

as _csa.so

For example in the terminal cp /path/to/csa/lib/libcsa.so /path/site-packages/octant/_csa.so

It seems to be working so far, I'll report back if I run into issues.

Cheers,

Gabriel

fagundesmo commented 8 years ago

Hi Gabriel,

let me see if I can help you. I have some notes on how I installed it in portuguese that I did while I was trying to install. However, I installed it under Ubuntu using gfortran (I'm not sure what your operational system is). Considering, you're running the installation in the same conditions that I installed.

svn checkout http://gridgen-c.googlecode.com/svn/gridgen gridgen svn checkout http://gridutils-c.googlecode.com/svn/ gridutils svn checkout http://csa-c.googlecode.com/svn/ csa svn checkout http://nn-c.googlecode.com/svn/ nn

cd nn/nn/ export FC=gfortran export F77=gfortran export CC=gcc export CXX=g++ ./configure --prefix=/home/mf/libsmodels make make install

cd ../../csa/csa/ export FC=gfortran export F77=gfortran export CC=gcc export CXX=g++ ./configure --prefix=/home/mf/libsmodels make make install

Na pasta csa terá um arquivo chamado csa.o, faça: cp csa.o ../../../../../../libsmodels/lib/

cd ../../gridutils/gridutils/ export FC=gfortran export F77=gfortran export CC=gcc export CXX=g++ ./configure --prefix=/home/mf/libsmodels CPPFLAGS=-I/home/mf/libsmodels/include LDFLAGS=-L/home/mf/libsmodels/lib make make install

cd ../../gridgen/ export FC=gfortran export F77=gfortran export CC=gcc export CXX=g++ ./configure -prefix=/home/mf/libsmodels CPPFLAGS=-I/home/mf/libsmodels/include LDFLAGS=-L/home/mf/libsmodels/lib

gedit makefile &

Replace in the makefile with the settings below: gedit makefile & CFLAGS = -g -O2 -Wall -I/home/mf/libsmodels/include LDFLAGS = -L/home/mf/libsmodels/lib LIBS = -lgu -lm -L/home/mf/libsmodels/lib

Close and sabe e keep following the commands below

make make lib make shlib make install

cd ../../../octant/ cd octant/

Modify in grid.py as showed below in the line ~898 (double check it)

gedit grid.py &

    self._libgridgen = np.ctypeslib.load_library('libgridgen.so',

'/home/mf/libsmodels/lib')

print octant.path[0]

    #self._libgridgen = np.ctypeslib.load_library('_gridgen',

octant.path[0])

save and close it. Afterwards, do one last modification:

cd ../ python setup.py build --fcompiler=gfortran

now in the dir ~/octant/octant/ open the file csa.py and modify with the same below:

_csa = np.ctypeslib.load_library('csa.o',

'/home/mf/libsmodels/libs(substitute with your path)')

Save and close it, go back to the dir

cd ../ python setup.py install --prefix=/home/mf/pythonmodels/octant

Adding the paths on .bashrc export PYTHONPATH=$PYTHONPATH:/home/mf/pythonmodels/octant export PYTHONPATH=$PYTHONPATH:/home/mf/pythonmodels/octant/include export PYTHONPATH=$PYTHONPATH:/home/mf/pythonmodels/octant/lib/python2.7/site-packages export PYTHONPATH=$PYTHONPATH:/home/mf/pythonmodels/octant/lib

Sorry for my mistakes in english, I hope that can help you set everything correct.

Cheers,

Matheus

On Wed, May 4, 2016 at 5:13 PM, Gabriel García Medina < notifications@github.com> wrote:

I just ran into the same problem. I know this is an old issue but I will write my workaround here for future reference.

To fix it I had to download csa from sakov's github and install it. This generates a libcsa.so which I copied to:

/path/to/my/python/installation/lib/python2.7/site-packages/octant/

as _csa.so

For example in the terminal cp /path/to/csa/lib/libcsa.so /path/site-packages/octant/_csa.so

It seems to be working so far, I'll report back if I run into issues.

Cheers,

Gabriel

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/hetland/octant/issues/4#issuecomment-216987373

drf5n commented 6 years ago

The googlecode links listed above seem broken, but you can do a recent version of csa-c with:

git clone https://github.com/sakov/csa-c.git
pushd csa-c/csa
./configure --prefix=$CONDA_PREFIX # or whereever
make clean install
popd