Skip to content

Commit

Permalink
Remove LCurve usage from the cookbook
Browse files Browse the repository at this point in the history
The recipes should do normal inversion. There should be a separate
document showing what LCurve can do
  • Loading branch information
leouieda committed Dec 10, 2015
1 parent 942755e commit f956f29
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
2 changes: 1 addition & 1 deletion cookbook/seismic_profile_vertical_smooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy
from fatiando import utils
from fatiando.seismic.profile import layered_straight_ray, LayeredStraight
from fatiando.inversion.regularization import Smoothness1D
from fatiando.inversion import Smoothness1D
from fatiando.vis import mpl

# Make a layered model
Expand Down
16 changes: 4 additions & 12 deletions cookbook/seismic_srtomo_damped.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
from fatiando.mesher import SquareMesh
from fatiando.seismic import ttime2d, srtomo
from fatiando.inversion import Damping, LCurve
from fatiando.inversion import Damping
from fatiando.vis import mpl
from fatiando import utils

Expand All @@ -26,19 +26,11 @@
# Make the mesh
mesh = SquareMesh(area, shape)
# and run the inversion
misfit = srtomo.SRTomo(tts, srcs, recs, mesh)
regularization = Damping(mesh.size)
# Will use the l-curve criterion to find the best regularization parameter
tomo = LCurve(misfit, regularization,
[10.**i for i in np.arange(0, 12, 1)], njobs=4).fit()
tomo = (srtomo.SRTomo(tts, srcs, recs, mesh) +
1e8*Damping(mesh.size))
tomo.fit()
mesh.addprop('vp', tomo.estimate_)

# Plot the L-curve annd print the regularization parameter estimated
mpl.figure()
mpl.title('L-curve: triangle marks the best solution')
tomo.plot_lcurve()
print "Estimated regularization parameter: %g" % (tomo.regul_param_)

# Calculate and print the standard deviation of the residuals
# Should be close to the data error if the inversion was able to fit the data
residuals = tomo[0].residuals()
Expand Down
15 changes: 4 additions & 11 deletions cookbook/seismic_srtomo_smooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
from fatiando.mesher import SquareMesh
from fatiando.seismic import ttime2d, srtomo
from fatiando.inversion import Smoothness2D, LCurve
from fatiando.inversion import Smoothness2D
from fatiando.vis import mpl
from fatiando import utils

Expand All @@ -26,18 +26,11 @@
# Make the mesh
mesh = SquareMesh(area, shape)
# and run the inversion
misfit = srtomo.SRTomo(tts, srcs, recs, mesh)
regularization = Smoothness2D(mesh.shape)
# Will use the l-curve criterion to find the best regularization parameter
tomo = LCurve(misfit, regularization, np.logspace(0, 12, 10), njobs=4).fit()
tomo = (srtomo.SRTomo(tts, srcs, recs, mesh) +
1e8*Smoothness2D(mesh.shape))
tomo.fit()
mesh.addprop('vp', tomo.estimate_)

# Plot the L-curve annd print the regularization parameter estimated
mpl.figure()
mpl.title('L-curve: triangle marks the best solution')
tomo.plot_lcurve()
print "Estimated regularization parameter: %g" % (tomo.regul_param_)

# Calculate and print the standard deviation of the residuals
# Should be close to the data error if the inversion was able to fit the data
residuals = tomo[0].residuals()
Expand Down

0 comments on commit f956f29

Please sign in to comment.