Skip to content

Commit

Permalink
Merge branch 'master' into fourier-processing
Browse files Browse the repository at this point in the history
Conflicts:
	cookbook/gravmag_transform_tga.py
	fatiando/gravmag/fourier.py
  • Loading branch information
leouieda committed Apr 30, 2015
2 parents f2eacb7 + cab653f commit 16260b4
Show file tree
Hide file tree
Showing 105 changed files with 17,229 additions and 43,857 deletions.
33 changes: 33 additions & 0 deletions .push-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
# Based on
# http://sleepycoders.blogspot.com.au/2013/03/sharing-travis-ci-generated-files.html
# and https://github.com/richfitz/wood
echo -e "Preparing to copy generated files to fatiando.github.io"
if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then
echo -e "Starting to update website\n"
cp -R doc/_build/html/ $HOME/keep
# Go to home and setup git
cd $HOME
git config --global user.email "[email protected]"
git config --global user.name "Leonardo Uieda"
git config --global github.user "leouieda"
echo -e "Cloning project"
# Clone the project, using the secret token. Uses /dev/null to avoid leaking decrypted key
git clone --quiet --branch=master --single-branch https://${GH_TOKEN}@github.com/fatiando/fatiando.github.io.git fatiando.org > /dev/null
cd fatiando.org
# Move the old branch out of the way and create a new one:
git branch -m master-old
git checkout --orphan master
# Delete all the files and replace with our good set
git rm -rf .
cp -Rf $HOME/keep/. $HOME/fatiando.org
# add, commit and push files
git add -f .
git commit -m "Travis build $TRAVIS_BUILD_NUMBER"
echo -e "Pushing..."
git push -fq origin master > /dev/null
echo -e "Uploaded generated files\n"
else
echo -e "This is a pull request, not copying files"
fi
echo -e "Done"
38 changes: 20 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,27 @@ python:
virtualenv:
system_site_packages: true
env:
- OMP_NUM_THREADS=4
global:
secure: cXRXecOJ0LpQBPfl/CvrrvuDTQpN0zZ1mpGG4rs02yWRmRoykqzJpPNHBHZ1MWEHGwOP9QqXjuPTRPEHYBP4I9V/7uHgrd4rIg50gonyr0LdQFLL9QxsM6SMH/zHyma+hpWmg2k3ad6zBd0GFkaACtVlS/x2F8JG+W6TrU/oL+I=
before_install:
- wget http://repo.continuum.io/miniconda/Miniconda-2.2.2-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -b
- export PATH=/home/travis/anaconda/bin:$PATH
# Update conda itself
- conda update --yes conda
- conda install --yes pip python=$TRAVIS_PYTHON_VERSION numpy scipy matplotlib nose sphinx imaging ipython
- pip install -q --use-mirrors coverage coveralls pep8
# Test the docs build before installing because sphinx breaks on Cython modules
- cd doc; sphinx-build -W -d _build/doctrees -b html . _build/html; cd ..
- wget http://repo.continuum.io/miniconda/Miniconda-2.2.2-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -b
- export PATH=/home/travis/anaconda/bin:$PATH
# Update conda itself
- conda update --yes conda
- conda install --yes pip python=$TRAVIS_PYTHON_VERSION numpy scipy matplotlib nose sphinx imaging ipython numba pep8==1.6.2
- pip install coverage==3.7.1 coveralls==0.5 sphinx_bootstrap_theme==0.4.5
install:
- python setup.py build
- pip install .
- python setup.py build_ext --inplace
- python setup.py build
- pip install .
- make clean && python setup.py build_ext --inplace
script:
- nosetests fatiando test -v --with-doctest --with-coverage --cover-package=fatiando
- make test
- make coverage
- make clean; cd doc; make html && cd ..
after_success:
- coveralls
notifications:
email: false
- coveralls
- bash .push-docs.sh
after_failure:
- make pep8
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ linkcheck: clean
cd doc; make linkcheck

view-docs:
cd doc/_build/html && python -m SimpleHTTPServer 8008
cd doc; make serve

.PHONY: test
test: build
Expand All @@ -50,7 +50,8 @@ coverage: build
test/

pep8:
pep8 --exclude=_version.py fatiando test cookbook
pep8 --show-source --show-pep8 --ignore=W503,E226,E241\
--exclude=_version.py fatiando test cookbook

pep8-stats:
pep8 --exclude=_version.py --statistics -qq fatiando test cookbook
Expand All @@ -60,7 +61,6 @@ package:

clean:
find . -name "*.so" -exec rm -v {} \;
#find "fatiando" -name "*.c" -exec rm -v {} \;
find . -name "*.pyc" -exec rm -v {} \;
rm -rvf build dist MANIFEST
# Trash generated by the doctests
Expand Down
58 changes: 28 additions & 30 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
|title|
=======

.. |title| image:: https://raw.githubusercontent.com/fatiando/logo/master/fatiando-banner-long.png
.. image:: https://raw.githubusercontent.com/fatiando/logo/master/fatiando-banner-long.png
:alt: Fatiando a Terra

`Website <http://www.fatiando.org>`__ |
`Docs <http://fatiando.readthedocs.org>`__ |
`Docs <http://fatiando.github.io/docs.html>`__ |
`Mailing list <https://groups.google.com/d/forum/fatiando>`__ |
`Google+ <https://plus.google.com/+FatiandoOrg>`__

A Python package for modeling and inversion in geophysics.

.. image:: http://img.shields.io/pypi/v/fatiando.svg?style=flat
.. image:: http://img.shields.io/pypi/v/fatiando.svg?style=flat-square
:alt: Latest PyPI version
:target: https://crate.io/packages/fatiando
.. image:: http://img.shields.io/pypi/dm/fatiando.svg?style=flat
.. image:: http://img.shields.io/pypi/dm/fatiando.svg?style=flat-square
:alt: Number of PyPI downloads
:target: https://crate.io/packages/fatiando/
.. image:: http://img.shields.io/badge/license-BSD-lightgrey.svg?style=flat
:alt: BSD 3 clause license
:target: https://github.com/fatiando/fatiando/blob/master/LICENSE.txt
.. image:: http://img.shields.io/travis/fatiando/fatiando.svg?style=flat
.. image:: http://img.shields.io/travis/fatiando/fatiando/master.svg?style=flat-square
:alt: Travis CI build status
:target: https://travis-ci.org/fatiando/fatiando
.. image:: http://img.shields.io/coveralls/fatiando/fatiando.svg?style=flat
.. image:: http://img.shields.io/coveralls/fatiando/fatiando/master.svg?style=flat-square
:alt: Test coverage status
:target: https://coveralls.io/r/fatiando/fatiando?branch=master
.. image:: http://img.shields.io/badge/doi-10.6084/m9.figshare.1115194-blue.svg?style=flat
:alt: doi:10.6084/m9.figshare.1115194
:target: http://dx.doi.org/10.6084/m9.figshare.1115194

.. image:: http://img.shields.io/badge/doi-10.5281/zenodo.16205-blue.svg?style=flat-square
:alt: doi:10.5281/zenodo.16205
:target: http://dx.doi.org/10.5281/zenodo.16205
.. image:: http://img.shields.io/badge/GITTER-JOIN_CHAT-brightgreen.svg?style=flat-square
:alt: gitter chat room at https://gitter.im/fatiando/fatiando
:target: https://gitter.im/fatiando/fatiando

Dependencies
------------

Expand All @@ -44,15 +41,11 @@ To install and run Fatiando, you'll need the following packages:
* PIL >= 1.1.7
* basemap >= 1.0.7
* gcc >= 4.8.2
* numba >= 0.17

You can get all of these on Linux, Mac, and Windows through
the `Anaconda distribution <http://continuum.io/downloads>`__.
See file ``requirements.txt`` and the
`documentation <http://fatiando.readthedocs.org>`__.

**Windows users**: See the
`install docs <http://fatiando.readthedocs.org/en/latest/install.html>`__
for special instructions on getting the dependencies installed.
See file ``requirements.txt``.

Installing
----------
Expand All @@ -71,6 +64,9 @@ from PyPI, this will be something like ``'0.2'``. If you installed from Github,
this will be the latest commit hash. This way you can track exactly what
version of Fatiando generated your results.

See the `documentation <http://fatiando.github.io/docs.html>`__ for detailed
instructions.

Citing
------

Expand All @@ -83,26 +79,28 @@ please **cite it** in your publications as::

Some of the methods implemented here are also **original research** by some of
the developers. Please **also cite the method papers**.
References are available in the documentation of each module.
See the
`CITATION.rst <https://github.com/fatiando/fatiando/blob/master/CITATION.rst>`__
file for more information.
file or the `documentation <http://fatiando.github.io/cite.html>`__
for more information.

Read `this blog post by Robin Wilson
<http://www.software.ac.uk/blog/2013-09-02-encouraging-citation-software-introducing-citation-files>`__
if you haven't heard of CITATION files.

Documentation
-------------

The latest documentation is available at ReadTheDocs. The docs reflects the
*master* branch on Github.
Getting help
------------

http://fatiando.readthedocs.org
Here are a few option to get in touch with us:

* `Open an issue on Github <https://github.com/fatiando/fatiando/issues>`__
* `Ask on the Gitter chat room <https://gitter.im/fatiando/fatiando>`__
* `Write to the mailing list <https://groups.google.com/d/forum/fatiando>`__

License
-------

Fatiando a Terra is free software: you can redistribute it and/or modify it
under the terms of the **BSD License**. A copy of this license is provided in
under the terms of the **BSD 3-clause License**. A copy of this license is provided in
`LICENSE.txt`.
90 changes: 90 additions & 0 deletions benchmarks/bench_gravmag_tesseroid.ipy
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Benchmark the performance of tesseroid
# Compare the fatiando implementation with Tesseroids
# (http://leouieda.com/tesseroids/)
import sys
import numpy as np
from numpy.testing import assert_array_almost_equal
from fatiando import gridder
from fatiando.gravmag import tesseroid
from fatiando.mesher import Tesseroid, TesseroidMesh
from fatiando.vis import mpl


def run_tesseroids(field):
if field == 'potential':
ratio = tesseroid.RATIO_POTENTIAL
field = 'pot'
elif field in 'gx gy gz'.split():
ratio = tesseroid.RATIO_G
elif field in 'gxx gxy gxz gyy gyz gzz'.split():
ratio = tesseroid.RATIO_GG
prog = 'tess{}'.format(field)
! $prog model.tmp -t$ratio < grid.tmp > out.tmp


def run_n_time(field, model, lon, lat, height):
# Create a model file and a grid file for Tesseroids
modfile = 'model.tmp'
with open(modfile, 'w') as f:
for t in model:
f.write('%g %g %g %g %g %g %g\n'
% (t.w, t.e, t.s, t.n, t.top, t.bottom, t.props['density']))
gridfile = 'grid.tmp'
np.savetxt(gridfile, np.transpose([lon, lat, height]), fmt='%g')

lines = ! wc -l model.tmp
print "lines", lines[0]
! head model.tmp
lines = ! wc -l grid.tmp
print "lines", lines[0]
! head grid.tmp

print "\nBenchmark {}:".format(field)
print "Tesseroids:"
%timeit run_tesseroids(field)
print "fatiando.tesseroid:"
%timeit getattr(tesseroid, field)(lon, lat, height, model)

ctess = np.loadtxt('out.tmp', unpack=True, usecols=[-1])
pytess = getattr(tesseroid, field)(lon, lat, height, model)
diff = np.abs(ctess - pytess)/np.abs(ctess).max()
assert_array_almost_equal(diff, np.zeros_like(lon), 3, 'Max diff: %.15g'
% (np.abs(ctess - pytess).max()))

! rm grid.tmp model.tmp out.tmp


# Make a model with few tesseroids to run fast
model = TesseroidMesh((100, 110, -5, 5, 0, -10000), (1, 5, 5))
model.addprop('density', 2700*np.ones(model.size))
area = [101, 109, -4, 4]
shape = [25, 25]
lon, lat, height = gridder.regular(area, shape, z=10000)

if 'profile' in sys.argv:
profile = True
if len(sys.argv) > 2:
field = sys.argv[1]
else:
field = 'gzz'
else:
profile = False
if len(sys.argv) > 1:
field = sys.argv[1]
else:
field = 'gzz'

if profile:
print "Profiling code:"
%prun getattr(tesseroid, field)(lon, lat, height, model)
else:
run_n_time(field, model, lon, lat, height)

print "\nLarge model, many points:\n"
model = TesseroidMesh((100, 110, -5, 5, 0, -10000), (1, 10, 10))
model.addprop('density', 2700*np.ones(model.size))
area = [101, 109, -4, 4]
shape = [50, 50]
lon, lat, height = gridder.regular(area, shape, z=10000)
run_n_time(field, model, lon, lat, height)

Loading

0 comments on commit 16260b4

Please sign in to comment.