Skip to content

ThirstyGeo/pygslib

 
 

Repository files navigation

PyGSLIB

This is two things:

  • a GSLIB FORTRAN code wrapped into python
  • a set of Python/Cython Function and Classes for drillhole processing, block model creation and manipulation, search neighborhood, VTK data visualization and exporting and non-linear geostatistical applications

Current version

version = '0.0.0.3.6'

This means that we are in a very early developing stage and the package is experimental!

Ipython notebook templates and examples.

The easiest way to use PyGSLIB is to modify the Ipython notebook provided as template and examples. Just change some input and enjoy the results.

Notes

If you are planning to use or modify this library you may understand the code organization.

The code is organized in two separated folders

  • cython_code
  • for_code

The fortran code is in the folder for_code and has 3 levels of implementation:

  1. A "low level" python module(s) generated automatically from FORTRAN 90 code (modified from the original FORTRAN 77 code and some non standard GSLIB programs). To compile the fortran code into python module we use f2py. This modules are "hided" (named __f*module name*.so)
  2. The python module(s) interfacing the module auto-generated with f2py. These are for high end users only and to develop algorithms. The examples (Ipython notebooks) that use this code are named with prefix _raw.
  3. [Deprecated] The algorithms modules, which are intended to simplify the use of pygslib.

Installation in Anaconda distribution (Linux/Window/OS)

The easiest way to install and work with PyGSLIB is to use Anaconda (conda) distributions. To install PyGSLIB in the root environment of your anaconda distribution follow the instructions below.

Binary Installation in Anaconda 64 bits distribution (Linux/Window 64)

There is a binary distribution at binstar.org. First install conda or anaconda distribution, if you don't have one, and run the command:

conda install -c https://conda.binstar.org/opengeostat pygslib

Installation from sources (pypi.python.org) in Anaconda 32/64 bits distribution (Linux) ------------ Install dependencies:

$ conda install numpy pandas matplotlib

Install PyGSLIB with easy_install or pip:

$ pip install pygslib

You may need access to gfortran compiler to compile the FORTRAN code. This is usually available in most Linux distributions.

Installation from sources (pypi.python.org) in Anaconda 32 bits distribution (Windows) ------------ Install dependencies, including mingw which comes with gfortran:

C:\>conda install mingw numpy pandas matplotlib

Install PyGSLIB with easy_install or pip using gfortran 32 bits compiler

C:\>pip install --global-option build_ext --global-option --compiler=mingw32 pygslib

Installation from sources (pypi.python.org) in Anaconda 64 bits distribution (Windows) ------------ Install dependencies:

C:\>conda install numpy pandas matplotlib

Install mingw with 64 bit compiler

C:\>conda install -c https://conda.binstar.org/omnia mingwpy

Install PyGSLIB with easy_install or pip using gfortran 64 bits compiler:

C:\>pip install --global-option build_ext --global-option --compiler=mingw32 pygslib

If you get an error like this:

File "C:\Users\Your_Path_Here\Anaconda\envs\test3\lib\site-packages\numpy\distutils\fcompiler\gnu.py",
line 337, in get_libraries raise NotImplementedError("Only MS compiler supported with gfortran on win64")
NotImplementedError: Only MS compiler supported with gfortran on win64

Don't worry, this is a known issue in numpys distutils. Go to the file

C:\Users\YYOUR_USER_NAME\Anaconda\lib\site-packages\numpy\distutils\fcompiler\gnu.py

or this file, if you are installing PyGSLIB in an environment

C:\Users\YYOUR_USER_NAME\Anaconda\envs\YOUR_ENVIRONMENT\lib\site-packages\numpy\distutils\fcompiler\gnu.py

around the line 337 you will see:

if is_win64():
    c_compiler = self.c_compiler
    if c_compiler and c_compiler.compiler_type == "msvc":
        return []
    else:
        raise NotImplementedError("Only MS compiler supported with gfortran on win64")

rewrite the code like this:

if is_win64():
        c_compiler = self.c_compiler
        if c_compiler and c_compiler.compiler_type == "msvc":
            return []
        else:
            return [] #raise NotImplementedError("Only MS compiler supported with gfortran on win64")

and rerun

C:\>pip install --global-option build_ext --global-option --compiler=mingw32 pygslib

This may fix the problem.

Note that this is a bug in numpy<1.10

Installation from source (from github.com)

This is the most update but unstable development version. You may manually install all the dependencies and make sure you have gfortran available:

git clone https://github.com/opengeostat/pygslib.git
cd pygslib
python setup.py install

To update this module as contributor, make changes and the update git (requesting a pull). To update the pypi repository:

python setup.py sdist upload -r pypi

To update conda repository(Linux):

conda skeleton pypi pygslib
conda build pygslib
anaconda upload /home/adrian/anaconda/conda-bld/linux-64/pygslib-0.0.0.3.3-nppy27_0.tar.bz2

Usage

See the Ipython noteebooks provided in the folder pygslib/Ipython_templates.

License

Copyright 2015, Adrian Martinez Vargas

Supported by Opengeostat Consulting @ http://opengeostat.com/

This software may be modified and distributed under the terms of the MIT license. See the LICENSE.txt file for details.

Tue 05 Jan. 2016

About

GSLIB fortran code wrapped into python

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Jupyter Notebook 96.7%
  • Python 1.7%
  • Fortran 1.6%