Skip to content

Conversation

@cako
Copy link

@cako cako commented Nov 29, 2025

Description

plot_perturbation has a small bug where the nbl is not properly addressed when plotting. This PR addressed that by applying the same slicing as plot_velocity.

Fix plotting of nbl
Copy link
Contributor

@EdCaunt EdCaunt left a comment

Choose a reason for hiding this comment

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

Minor comment, but generally a useful fix. Thanks!

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants