Skip to content

Commit

Permalink
Use finite-diff derivatives in Euler tests
Browse files Browse the repository at this point in the history
The Euler deconvolution tests were using FFT derivatives and failing
because of them. I exchanged for derivatives approximated by finite
differences in the forward modeling. This was the Euler tests don't
depend of the performance of the FFT derivs.
  • Loading branch information
leouieda committed Apr 27, 2015
1 parent 72a3de6 commit db33b3a
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions test/test_gravmag_euler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import division
import numpy as np
from fatiando.gravmag.euler import Classic, ExpandingWindow, MovingWindow
from fatiando.gravmag import sphere, transform
from fatiando.gravmag import sphere
from fatiando.mesher import Sphere
from fatiando import utils, gridder

Expand All @@ -19,17 +19,22 @@ def setup():
global model, x, y, z, inc, dec, struct_ind, field, xderiv, yderiv, \
zderiv, base, pos
inc, dec = -30, 50
pos = np.array([1000, 1000, 200])
pos = np.array([1000, 1200, 200])
model = Sphere(pos[0], pos[1], pos[2], 1,
{'magnetization': utils.ang2vec(10000, inc, dec)})
struct_ind = 3
shape = (128, 128)
x, y, z = gridder.regular((0, 3000, 0, 3000), shape, z=-1)
shape = (200, 200)
x, y, z = gridder.regular((0, 3000, 0, 3000), shape, z=-100)
base = 10
field = utils.nt2si(sphere.tf(x, y, z, [model], inc, dec)) + base
xderiv = transform.derivx(x, y, field, shape)
yderiv = transform.derivy(x, y, field, shape)
zderiv = transform.derivz(x, y, field, shape)
field = sphere.tf(x, y, z, [model], inc, dec) + base
# Use finite difference derivatives so that these tests don't depend on the
# performance of the FFT derivatives.
xderiv = (sphere.tf(x + 1, y, z, [model], inc, dec)
- sphere.tf(x - 1, y, z, [model], inc, dec))/2
yderiv = (sphere.tf(x, y + 1, z, [model], inc, dec)
- sphere.tf(x, y - 1, z, [model], inc, dec))/2
zderiv = (sphere.tf(x, y, z + 1, [model], inc, dec)
- sphere.tf(x, y, z - 1, [model], inc, dec))/2


def test_euler_classic_sphere_mag():
Expand Down

0 comments on commit db33b3a

Please sign in to comment.