Skip to content

Commit 4892dbe

Browse files
authored
Merge pull request #16 from geoscixyz/tomography-inversion
2D crosswell tomography app
2 parents 43d1d24 + 4dd35a2 commit 4892dbe

7 files changed

+1595
-30
lines changed

geoscilabs/inversion/LinearInversion.py renamed to geoscilabs/inversion/LinearInversionCG.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
FloatText,
2222
IntText,
2323
SelectMultiple,
24+
RadioButtons,
2425
)
2526
import ipywidgets as widgets
2627

2728

28-
class LinearInversionApp(object):
29+
class LinearInversionCGApp(object):
2930
"""docstring for LinearInversionApp"""
3031

3132
# Parameters for sensitivity matrix, G
@@ -53,7 +54,7 @@ class LinearInversionApp(object):
5354
save = None
5455

5556
def __init__(self):
56-
super(LinearInversionApp, self).__init__()
57+
super(LinearInversionCGApp, self).__init__()
5758

5859
@property
5960
def G(self):
@@ -205,6 +206,7 @@ def plot_model(
205206
self.floor = floor
206207

207208
option_bools = [False, False, False]
209+
208210
for item in option:
209211
if item == "kernel":
210212
option_bools[0] = True
@@ -263,7 +265,7 @@ def get_problem_survey(self):
263265
survey.pair(prob)
264266
return survey, prob
265267

266-
def run_inversion(
268+
def run_inversion_cg(
267269
self,
268270
maxIter=60,
269271
m0=0.0,
@@ -327,6 +329,7 @@ def run_inversion(
327329

328330
def plot_inversion(
329331
self,
332+
mode="Run",
330333
maxIter=60,
331334
m0=0.0,
332335
mref=0.0,
@@ -339,13 +342,12 @@ def plot_inversion(
339342
alpha_s=1.0,
340343
alpha_x=1.0,
341344
use_target=False,
342-
run=True,
343345
option="model",
344346
i_iteration=1,
345347
):
346348

347-
if run:
348-
self.model, self.pred, self.save = self.run_inversion(
349+
if mode == "Run":
350+
self.model, self.pred, self.save = self.run_inversion_cg(
349351
maxIter=maxIter,
350352
m0=m0,
351353
mref=mref,
@@ -371,12 +373,12 @@ def plot_inversion(
371373
fig, axes = plt.subplots(1, 3, figsize=(14 * 1.2, 3 * 1.2))
372374

373375
axes[0].plot(self.mesh.vectorCCx, self.m)
374-
if run:
376+
if mode == "Run":
375377
axes[0].plot(self.mesh.vectorCCx, self.model[i_plot])
376378
axes[0].set_ylim([-2.5, 2.5])
377379
axes[1].errorbar(x=self.jk, y=self.data, yerr=self.uncertainty, color="k", lw=1)
378380
axes[1].plot(self.jk, self.data, "ko")
379-
if run:
381+
if mode == "Run":
380382
axes[1].plot(self.jk, self.pred[i_plot], "bx")
381383
axes[1].legend(("Observed", "Predicted"))
382384
axes[0].legend(("True", "Pred"))
@@ -400,7 +402,7 @@ def plot_inversion(
400402
i_iteration = max_iteration
401403

402404
if option == "misfit":
403-
if not run:
405+
if mode == "Explore":
404406
axes[0].plot(self.mesh.vectorCCx, self.model[i_iteration])
405407
axes[1].plot(self.jk, self.pred[i_iteration], "bx")
406408
# axes[0].legend(("True", "Pred", ("%ith")%(i_iteration)))
@@ -444,7 +446,7 @@ def plot_inversion(
444446
axes[2].set_title("Misfit curves")
445447

446448
elif option == "tikhonov":
447-
if not run:
449+
if mode == "Explore":
448450
axes[0].plot(self.mesh.vectorCCx, self.model[i_iteration])
449451
axes[1].plot(self.jk, self.pred[i_iteration], "bx")
450452
# axes[0].legend(("True", "Pred", ("%ith")%(i_iteration)))
@@ -567,6 +569,9 @@ def interact_plot_model(self):
567569
def interact_plot_inversion(self, maxIter=30):
568570
interact(
569571
self.plot_inversion,
572+
mode=RadioButtons(
573+
description="mode", options=["Run", "Explore"], value="Run"
574+
),
570575
maxIter=IntText(value=maxIter),
571576
m0=FloatSlider(
572577
min=-2, max=2, step=0.05, value=0.0, continuous_update=False
@@ -586,7 +591,6 @@ def interact_plot_inversion(self, maxIter=30):
586591
),
587592
alpha_s=FloatText(value=1e-10),
588593
alpha_x=FloatText(value=0),
589-
run=True,
590594
target=False,
591595
option=ToggleButtons(options=["misfit", "tikhonov"], value="misfit"),
592596
i_iteration=IntSlider(

0 commit comments

Comments
 (0)