Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
build_taup_model() fails for constant-velocity models with more than 2 layers #2264
A layered constant-velocity model can have more first-order discontinuities than a piecewise-linear model. The number of first-order discontinuities in a constant-velocity model is number of layers + 1. Since the minimum number of layers is 1, this should never be less than 2. [n.b. that other issues prevent construction of a 1-layer model, but who cares?]
Here is where the storage for discontinuities is set up:
As you can see, the maximum number was the number of layers and the minimum number was 3. This meant that this worked for constant-velocity models with 2 layers, but no more.
I don't understand why numpy.empty() was used; There's no need for speed. Instead I'm proposing numpy.zeros().
The test is a variant on:
pushed a commit
this pull request
Nov 16, 2018
I've added tests - I've only checked that the taup test suite has no errors (3 tests skipped).
I think this should be classed as a bug fix - does that mean I need to rebase against a different branch?
I think it was a mistaken attempt to fix the problem that I've identified - it meant that build_taup_model() started working for models with 2 layers, but no other models. Single-layer models fail for a whole bunch of reasons, starting with, but not limited to, not being able to find the moho. Larger models because the maximum possible number of discontinuities is the number of layer plus one, and this line of code was missing the plus one. With the "plus one" fix, the minimum value can be removed.