Giter Site home page Giter Site logo

arnaldorusso / divand.py Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gher-uliege/divand.py

0.0 2.0 0.0 379 KB

divand performs an n-dimensional variational analysis of arbitrarily located observations (python interface)

License: GNU General Public License v2.0

Shell 33.68% Python 66.32%

divand.py's Introduction

divand.py

Build Status

divand performs an n-dimensional variational analysis of arbitrarily located observations (python interface).
This package is a python interface to divand, written in Julia.

The primary use case of divand.py is to build web service and therefore the only OS supported by divand.py is Linux.

Installation

Besides Python and NumPy you need to:

  • Install Julia
  • Install the Julia package PyCall
Pkg.add("PyCall")
  • Install the Julia package divand
Pkg.clone("https://github.com/gher-ulg/divand.jl")

divand.py is tested with Python 2.7 but should also work with Python 3 once pyjulia is installed properly.

git clone https://github.com/JuliaPy/pyjulia
cd pyjulia/
python setup.py install
  • Clone this package
git clone https://github.com/gher-ulg/divand.py

Testing

You are advised to try one of these examples in the directory examples:

The environment variable PYTHONPATH should contain the directory with the file divand.py.

You can set this variable for the current shell and then run the example:

export PYTHONPATH="$HOME/src/divand.py/divand:$PYTHONPATH"
python divand_argo.py

or just for a single call of the python script (the following command should be on one line):

PYTHONPATH="$HOME/src/divand.py/divand:$PYTHONPATH" python divand_argo.py

Note that you should adapt the path in the previous example ($HOME/src/divand.py/divand) to match the installation location of divand.py.

Troubleshooting

Segmentation fault at initialization of pyjulia

On Ubuntu, the default python interpreter (/usr/bin/python) produces a segmentation fault because it is linked statically to libpython2.7.so. As a work-around, use the python interpreter from e.g. Conda after installing the julia package Conda.jl. The python interpreter is located at $HOME/.julia/v0.6/Conda/deps/usr/bin/python2.7.

C++ runtime library error

If you see the following error:

OSError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/abarth/opt/julia-3c9d75391c/bin/../lib/libjulia.so.0.5)

Define the variable LD_PRELOAD before starting python or (ipython)

export LD_PRELOAD="$HOME/opt/julia-3c9d75391c/lib/julia/libstdc++.so.6"

You should adapt the path in the previous command to match the installation location of Julia.

Python crash

On some systems, python crashes on j = julia.Julia() (JuliaPy/pyjulia#66). Rebuilding PyCall after installing juliapy seems to solve this issue. In Julia, run the following command:

Pkg.build("PyCall")

Exception 'UVError'

could not spawn `/home/abarth/.local/lib/python2.7/site-packages/julia-0.1.1-py2.7.egg/julia/../fake-julia/julia -Cx86-64 -J/home/abarth/opt/julia-0.6.0/lib/julia/sys.so --compile=yes --depwarn=yes -O0 --output-ji /home/abarth/Test/julia-v0.6-dev/lib/pyjulia2-v0.6/PyCall.ji --output-incremental=yes --startup-file=no --history-file=no --color=no --eval 'while !eof(STDIN)
    eval(Main, deserialize(STDIN))
end
'`: no such file or directory (ENOENT)Traceback (most recent call last):
  File "test_simple_module.py", line 2, in <module>
    j = julia.Julia()
  File "/home/abarth/.local/lib/python2.7/site-packages/julia-0.1.1-py2.7.egg/julia/core.py", line 361, in __init__
    self._call(u"using PyCall")
  File "/home/abarth/.local/lib/python2.7/site-packages/julia-0.1.1-py2.7.egg/julia/core.py", line 403, in _call
    self.check_exception(src)
  File "/home/abarth/.local/lib/python2.7/site-packages/julia-0.1.1-py2.7.egg/julia/core.py", line 423, in check_exception
    .format(exception_type, src))
julia.core.JuliaError: Exception 'UVError' occurred while calling julia code:
using PyCall
Pkg.build("PyCall")
using PyCall

Julia exception: MethodError

If you optain the following error by running one of the examples, consider to upgrade PyCall (to a version later than 1.14 or using the git version)

WARNING: redefining constant JULIA_HOME
Traceback (most recent call last):
  File "divand_small.py", line 25, in <module>
    va = divand(mask, (pm, pn), (xi, yi), (x, y), v, (lenx, leny), epsilon2)
  File "/home/abarth/src/divand.py/divand/divand.py", line 14, in divand
    x, f, corlen, epsilon2)
RuntimeError: Julia exception: MethodError(divand.divandrunfi, (Bool[true true true true; true true true true; true true true true], ([2.0 2.0 2.0 2.0; 2.0 2.0 2.0 2.0; 2.0 2.0 2.0 2.0], [3.0 3.0 3.0 3.0; 3.0 3.0 3.0 3.0; 3.0 3.0 3.0 3.0]), ([0.0 0.0 0.0 0.0; 0.5 0.5 0.5 0.5; 1.0 1.0 1.0 1.0], [0.0 0.333333 0.666667 1.0; 0.0 0.333333 0.666667 1.0; 0.0 0.333333 0.666667 1.0]), ([1.0e-10 0.5 1.0; 1.0e-10 0.5 1.0; 1.0e-10 0.5 1.0], [1.0e-10 1.0e-10 1.0e-10; 0.5 0.5 0.5; 1.0 1.0 1.0]), [6.0e-10 0.14112 -0.279415; -5.93995e-10 -0.139708 0.276619; 5.76102e-10 0.135499 -0.268286], (0.15, 0.15), 0.05), 0x000000000000553e)

Installation of python modules

You may want to use modules such as netCDF4 or matplotlib. Two possibilies are offered, starting in the $HOME/.julia/v0.6/Conda/deps/usr/bin/python2.7 directory:

  1. Using the Conda installation:
conda install numpy
  1. Using pip command:
pip install numpy

The installed packages can be listed using pip list or conda list.

Note that the modules available through Conda are those in one of the following repositories:

Python 3

See python3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.