Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/seismic/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def plot_perturbation(model, model1, colorbar=True):
domain_size = 1.e-3 * np.array(model.domain_size)
extent = [model.origin[0], model.origin[0] + domain_size[0],
model.origin[1] + domain_size[1], model.origin[1]]
dv = np.transpose(model.vp.data) - np.transpose(model1.vp.data)
slices = tuple(slice(model.nbl, -model.nbl) for _ in range(2))
slices1 = tuple(slice(model1.nbl, -model1.nbl) for _ in range(2))
dv = np.transpose(model.vp.data[slices]) - np.transpose(model1.vp.data[slices1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would personally check model.nbl == model1.nbl and raise a suitable ValueError if not (probably also check the size of both models match whilst you're at it).

That way you only need a single slices which would be tidier and easier to read in my opinion.

Minor note, you can also do slices = (slice(model.nbl, -model.nbl),) * 2 for concision, although this is arguably less explicit. A matter of personal preference I would say.


plot = plt.imshow(dv, animated=True, cmap=cm.jet,
vmin=min(dv.reshape(-1)), vmax=max(dv.reshape(-1)),
Expand Down