Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taup fix for models with no discontinuities #3244

Merged
merged 3 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Changes:
- obspy.io.gcf:
* Fixed an issue in algorithm to split and encode last few data into GCF
blocks (see #3252)
- obspy.taup:
* bugfix to allow calculations for a model with no discontinuities
(see #3070, #3244)

1.4.0 (doi: 10.5281/zenodo.6645832)
===================================
Expand Down
2 changes: 1 addition & 1 deletion obspy/taup/taup_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def run(self):
os.makedirs(dirname)
self.tau_model.serialize(self.output_filename)
if self.debug:
print("Done Saving " + self.output_filename)
print("Done Saving " + str(self.output_filename))
except IOError as e:
print("Tried to write!\n Caught IOError. Do you have write "
"permission in this directory?", e)
Expand Down
8 changes: 3 additions & 5 deletions obspy/taup/tests/test_tau.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,14 +1034,12 @@ def test_arrivals_class(self):
def test_regional_models(self, testdata):
"""
Tests small regional models as this used to not work.

Note: It looks like too much work to get a 1-layer model working.
The problem is first in finding the moho, and second in coarsely-
sampling slowness. Also, why bother.
"""
model_names = ["2_layer_model", "5_layer_model",
model_names = ["1_layer_model", "2_layer_model", "5_layer_model",
"2_layer_no_discontinuity_model"]
expected_results = [
[("p", 18.143), ("sP", 22.054), ("s", 31.509), ("PP", 4107.380),
("SP", 5619.257), ("PS", 5621.396), ("SS", 7133.265)],
[("p", 18.143), ("P", 19.202), ("Pn", 19.202), ("P", 19.884),
("sP", 22.054), ("pP", 23.023), ("pP", 23.038), ("sP", 25.656),
("sP", 25.759), ("s", 31.509), ("S", 33.395), ("Sn", 33.395),
Expand Down
7 changes: 7 additions & 0 deletions obspy/taup/velocity_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,13 @@ def fix_discontinuity_depths(self):
above['bot_p_velocity'] != below['top_p_velocity'],
above['bot_s_velocity'] != below['top_s_velocity'])

if len(mask) == 0:
# Special case where have no discontinuities
self.moho_depth = temp_moho_depth
self.cmb_depth = temp_cmb_depth
self.iocb_depth = temp_iocb_depth
return

# Find discontinuity closest to current Moho
moho_diff = np.abs(self.moho_depth - above['bot_depth'])
moho_diff[~mask] = moho_min
Expand Down