Skip to content

Commit

Permalink
Cleaned devitoseismic
Browse files Browse the repository at this point in the history
  • Loading branch information
fpicetti committed Apr 18, 2022
1 parent 8912cca commit 7712f43
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 107 deletions.
6 changes: 3 additions & 3 deletions tutorials/devitoseismic/acoustic/acoustic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@ def run(shape=(50, 50, 50), spacing=(20.0, 20.0, 20.0), tn=1000.0,
solver.forward(save=save, vp=2.0)

if not full_run:
return summary.gflopss, summary.oi, summary.timings, [rec, u.csg_nonlinear]
return summary.gflopss, summary.oi, summary.timings, [rec, u.data]

# Smooth velocity
initial_vp = Function(name='v0', grid=solver.model.grid, space_order=space_order)
smooth(initial_vp, solver.model.vp)
dm = np.float32(initial_vp.data ** (-2) - solver.model.vp.csg_nonlinear ** (-2))
dm = np.float32(initial_vp.data ** (-2) - solver.model.vp.data ** (-2))

info("Applying Adjoint")
solver.adjoint(rec, autotune=autotune)
info("Applying Born")
solver.jacobian(dm, autotune=autotune)
info("Applying Gradient")
solver.jacobian_adjoint(rec, u, autotune=autotune, checkpointing=checkpointing)
return summary.gflopss, summary.oi, summary.timings, [rec, u.csg_nonlinear]
return summary.gflopss, summary.oi, summary.timings, [rec, u.data]


@pytest.mark.parametrize('shape', [(101,), (51, 51), (16, 16, 16)])
Expand Down
2 changes: 1 addition & 1 deletion tutorials/devitoseismic/acoustic/wavesolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def jacobian_adjoint(self, rec, u, src=None, v=None, grad=None, model=None,
rec=rec, dt=dt, grad=grad, **kwargs)

# Run forward
wrp = Revolver(cp, wrap_fw, wrap_rev, n_checkpoints, rec.csg_nonlinear.shape[0] - 2)
wrp = Revolver(cp, wrap_fw, wrap_rev, n_checkpoints, rec.data.shape[0] - 2)
wrp.apply_forward()
summary = wrp.apply_reverse()
else:
Expand Down
4 changes: 2 additions & 2 deletions tutorials/devitoseismic/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,15 +380,15 @@ def update(self, name, value):
# Update the square slowness according to new value
if isinstance(value, np.ndarray):
if value.shape == param.shape:
param.csg_nonlinear[:] = value[:]
param.data[:] = value[:]
elif value.shape == self.shape:
initialize_function(param, value, self.nbl)
else:
raise ValueError("Incorrect input size %s for model" % value.shape +
" %s without or %s with padding" % (self.shape,
param.shape))
else:
param.csg_nonlinear = value
param.data = value

@property
def m(self):
Expand Down
4 changes: 2 additions & 2 deletions tutorials/devitoseismic/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def plot_velocity(model, source=None, receiver=None, colorbar=True, cmap="jet"):

slices = tuple(slice(model.nbl, -model.nbl) for _ in range(2))
if getattr(model, 'vp', None) is not None:
field = model.vp.csg_nonlinear[slices]
field = model.vp.data[slices]
else:
field = model.lam.csg_nonlinear[slices]
field = model.lam.data[slices]
plot = plt.imshow(np.transpose(field), animated=True, cmap=cmap,
vmin=np.min(field), vmax=np.max(field),
extent=extent)
Expand Down
2 changes: 1 addition & 1 deletion tutorials/devitoseismic/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def resample(self, dt=None, num=None, rtol=1e-5, order=3):

# Return new object
return PointSource(name=self.name, grid=self.grid, data=new_traces,
time_range=new_time_range, coordinates=self.coordinates.csg_nonlinear)
time_range=new_time_range, coordinates=self.coordinates.data)

# Pickling support
_pickle_kwargs = SparseTimeFunction._pickle_kwargs + ['time_range']
Expand Down
97 changes: 0 additions & 97 deletions tutorials/devitoseismic/test_seismic_utils.py

This file was deleted.

2 changes: 1 addition & 1 deletion tutorials/devitoseismic/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def adj_src(self):
t0=self._t0w, a=self._a)
# Revert time axis to have a proper shot record and not compute on zeros
for i in range(self.nrec):
adj_src.csg_nonlinear[:, i] = adj_src.wavelet[::-1]
adj_src.data[:, i] = adj_src.wavelet[::-1]
return adj_src

@property
Expand Down

0 comments on commit 7712f43

Please sign in to comment.