Skip to content

Commit

Permalink
PEP8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
leouieda committed Dec 10, 2015
1 parent 782207a commit 942755e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 21 deletions.
4 changes: 2 additions & 2 deletions cookbook/seismic_srtomo_sharp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
# Make the mesh
mesh = SquareMesh(area, shape)
# and run the inversion
tomo = srtomo.SRTomo(tts, srcs, recs, mesh) \
+ 30*TotalVariation2D(1e-10, mesh.shape)
tomo = (srtomo.SRTomo(tts, srcs, recs, mesh) +
30*TotalVariation2D(1e-10, mesh.shape))
# Since Total Variation is a non-linear function, then the tomography becomes
# non-linear. So we need to configure fit to use the Levemberg-Marquardt
# algorithm, a gradient descent method, that requires an initial estimate
Expand Down
4 changes: 2 additions & 2 deletions fatiando/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
implementing inverse problems. There you'll find ready to use regularization,
optimization methods, and templates to implement new inversion methods.
Inversions implemented in Fatiando leverage :mod:`fatiando.inversion`, providing
a common interface and usage patters. For examples, see modules
Inversions implemented in Fatiando leverage :mod:`fatiando.inversion`,
providing a common interface and usage patters. For examples, see modules
:mod:`fatiando.seismic.epic2d`,
:mod:`fatiando.seismic.srtomo`,
:mod:`fatiando.gravmag.basin2d`,
Expand Down
18 changes: 6 additions & 12 deletions fatiando/gravmag/basin2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,18 +473,12 @@ def jacobian(self, p):
verts = self.verts
delta = 1.
jac = np.empty((self.ndata, self.nparams), dtype=np.float)
jac[:, 0] = (
talwani.gz(x, z, [Polygon(verts + [[x1, z1 + delta], [x2, z2]],
props)])
- talwani.gz(x, z, [Polygon(verts + [[x1, z1 - delta], [x2, z2]],
props)])
)/(2*delta)
jac[:, 1] = (
talwani.gz(x, z, [Polygon(verts + [[x1, z1], [x2, z2 + delta]],
props)])
- talwani.gz(x, z, [Polygon(verts + [[x1, z1], [x2, z2 - delta]],
props)])
)/(2*delta)
z1p = [Polygon(verts + [[x1, z1 + delta], [x2, z2]], props)]
z1m = [Polygon(verts + [[x1, z1 - delta], [x2, z2]], props)]
jac[:, 0] = (talwani.gz(x, z, z1p) - talwani.gz(x, z, z1m))/(2*delta)
z2p = [Polygon(verts + [[x1, z1], [x2, z2 + delta]], props)]
z2m = [Polygon(verts + [[x1, z1], [x2, z2 - delta]], props)]
jac[:, 1] = (talwani.gz(x, z, z2p) - talwani.gz(x, z, z2m))/(2*delta)
return jac

def fmt_estimate(self, p):
Expand Down
2 changes: 1 addition & 1 deletion fatiando/gravmag/euler.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(self, x, y, z, field, xderiv, yderiv, zderiv,
"Invalid structural index '{}'. Should be >= 0".format(
structural_index)
super().__init__(
data=-x*xderiv - y*yderiv -z*zderiv - structural_index*field,
data=-x*xderiv - y*yderiv - z*zderiv - structural_index*field,
nparams=4, islinear=True)
self.x = x
self.y = y
Expand Down
8 changes: 4 additions & 4 deletions fatiando/seismic/epic2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ def predicted(self, p):
"Calculate the predicted travel time data given a parameter vector."
x, y = p
alpha = 1/self.vs - 1/self.vp
pred = alpha*np.sqrt((self.recs[:, 0] - x)**2
+ (self.recs[:, 1] - y)**2)
pred = alpha*np.sqrt((self.recs[:, 0] - x)**2 +
(self.recs[:, 1] - y)**2)
return pred

def jacobian(self, p):
"Calculate the Jacobian matrix for the inversion."
x, y = p
alpha = 1/self.vs - 1/self.vp
sqrt = np.sqrt((self.recs[:, 0] - x)**2
+ (self.recs[:, 1] - y)**2)
sqrt = np.sqrt((self.recs[:, 0] - x)**2 +
(self.recs[:, 1] - y)**2)
jac = np.empty((self.ndata, self.nparams))
jac[:, 0] = -alpha*(self.recs[:, 0] - x)/sqrt
jac[:, 1] = -alpha*(self.recs[:, 1] - y)/sqrt
Expand Down

0 comments on commit 942755e

Please sign in to comment.