earthsciencekit 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- earthsciencekit/__init__.py +6 -0
- earthsciencekit/_validation.py +62 -0
- earthsciencekit/atmosphere/__init__.py +57 -0
- earthsciencekit/atmosphere/core/__init__.py +5 -0
- earthsciencekit/atmosphere/core/base.py +10 -0
- earthsciencekit/atmosphere/systems/__init__.py +1 -0
- earthsciencekit/atmosphere/systems/dynamics.py +208 -0
- earthsciencekit/atmosphere/systems/hydrostatics.py +214 -0
- earthsciencekit/atmosphere/systems/moisture.py +162 -0
- earthsciencekit/atmosphere/systems/thermodynamics.py +222 -0
- earthsciencekit/atmosphere/tests/__init__.py +0 -0
- earthsciencekit/atmosphere/tests/test_models.py +741 -0
- earthsciencekit/atmosphere/tests/test_physics.py +81 -0
- earthsciencekit/atmosphere/visualizers/__init__.py +9 -0
- earthsciencekit/climate/__init__.py +63 -0
- earthsciencekit/climate/core/__init__.py +5 -0
- earthsciencekit/climate/core/base.py +10 -0
- earthsciencekit/climate/systems/__init__.py +1 -0
- earthsciencekit/climate/systems/carbon.py +76 -0
- earthsciencekit/climate/systems/forcing.py +124 -0
- earthsciencekit/climate/systems/radiation.py +214 -0
- earthsciencekit/climate/systems/response.py +402 -0
- earthsciencekit/climate/systems/sea_level.py +77 -0
- earthsciencekit/climate/tests/__init__.py +0 -0
- earthsciencekit/climate/tests/test_models.py +1015 -0
- earthsciencekit/climate/tests/test_physics.py +16 -0
- earthsciencekit/climate/visualizers/__init__.py +9 -0
- earthsciencekit/constants/__init__.py +23 -0
- earthsciencekit/geophysics/__init__.py +77 -0
- earthsciencekit/geophysics/core/__init__.py +5 -0
- earthsciencekit/geophysics/core/base.py +10 -0
- earthsciencekit/geophysics/systems/__init__.py +1 -0
- earthsciencekit/geophysics/systems/deformation.py +161 -0
- earthsciencekit/geophysics/systems/dynamo.py +159 -0
- earthsciencekit/geophysics/systems/figure.py +292 -0
- earthsciencekit/geophysics/systems/gravity.py +235 -0
- earthsciencekit/geophysics/systems/magnetism.py +354 -0
- earthsciencekit/geophysics/tests/__init__.py +0 -0
- earthsciencekit/geophysics/tests/test_models.py +898 -0
- earthsciencekit/geophysics/tests/test_physics.py +171 -0
- earthsciencekit/geophysics/visualizers/__init__.py +9 -0
- earthsciencekit/integrators/__init__.py +62 -0
- earthsciencekit/oceanography/__init__.py +61 -0
- earthsciencekit/oceanography/core/__init__.py +5 -0
- earthsciencekit/oceanography/core/base.py +10 -0
- earthsciencekit/oceanography/systems/__init__.py +1 -0
- earthsciencekit/oceanography/systems/circulation.py +388 -0
- earthsciencekit/oceanography/systems/hydrography.py +212 -0
- earthsciencekit/oceanography/systems/inertial.py +86 -0
- earthsciencekit/oceanography/systems/waves.py +281 -0
- earthsciencekit/oceanography/tests/__init__.py +0 -0
- earthsciencekit/oceanography/tests/test_models.py +916 -0
- earthsciencekit/oceanography/tests/test_physics.py +102 -0
- earthsciencekit/oceanography/visualizers/__init__.py +9 -0
- earthsciencekit/plate_tectonics/__init__.py +59 -0
- earthsciencekit/plate_tectonics/core/__init__.py +5 -0
- earthsciencekit/plate_tectonics/core/base.py +10 -0
- earthsciencekit/plate_tectonics/systems/__init__.py +1 -0
- earthsciencekit/plate_tectonics/systems/boundaries.py +201 -0
- earthsciencekit/plate_tectonics/systems/cooling.py +238 -0
- earthsciencekit/plate_tectonics/systems/isostasy.py +157 -0
- earthsciencekit/plate_tectonics/systems/kinematics.py +290 -0
- earthsciencekit/plate_tectonics/tests/__init__.py +0 -0
- earthsciencekit/plate_tectonics/tests/test_models.py +920 -0
- earthsciencekit/plate_tectonics/tests/test_physics.py +94 -0
- earthsciencekit/plate_tectonics/visualizers/__init__.py +9 -0
- earthsciencekit/py.typed +0 -0
- earthsciencekit/results.py +73 -0
- earthsciencekit/seismology/__init__.py +59 -0
- earthsciencekit/seismology/core/__init__.py +5 -0
- earthsciencekit/seismology/core/base.py +10 -0
- earthsciencekit/seismology/systems/__init__.py +1 -0
- earthsciencekit/seismology/systems/interfaces.py +102 -0
- earthsciencekit/seismology/systems/rays.py +221 -0
- earthsciencekit/seismology/systems/sources.py +249 -0
- earthsciencekit/seismology/systems/waves.py +268 -0
- earthsciencekit/seismology/tests/__init__.py +0 -0
- earthsciencekit/seismology/tests/test_models.py +852 -0
- earthsciencekit/seismology/tests/test_physics.py +100 -0
- earthsciencekit/seismology/visualizers/__init__.py +9 -0
- earthsciencekit/tests/__init__.py +0 -0
- earthsciencekit/tests/test_core.py +181 -0
- earthsciencekit/tests/test_relations.py +36 -0
- earthsciencekit/units/__init__.py +66 -0
- earthsciencekit/visualizers/__init__.py +45 -0
- earthsciencekit/volcanology/__init__.py +61 -0
- earthsciencekit/volcanology/core/__init__.py +5 -0
- earthsciencekit/volcanology/core/base.py +10 -0
- earthsciencekit/volcanology/systems/__init__.py +1 -0
- earthsciencekit/volcanology/systems/eruptions.py +161 -0
- earthsciencekit/volcanology/systems/geochemistry.py +226 -0
- earthsciencekit/volcanology/systems/geochronology.py +304 -0
- earthsciencekit/volcanology/systems/magma.py +190 -0
- earthsciencekit/volcanology/tests/__init__.py +0 -0
- earthsciencekit/volcanology/tests/test_models.py +485 -0
- earthsciencekit/volcanology/tests/test_physics.py +176 -0
- earthsciencekit/volcanology/visualizers/__init__.py +9 -0
- earthsciencekit-0.2.0.dist-info/METADATA +127 -0
- earthsciencekit-0.2.0.dist-info/RECORD +102 -0
- earthsciencekit-0.2.0.dist-info/WHEEL +5 -0
- earthsciencekit-0.2.0.dist-info/licenses/LICENSE +15 -0
- earthsciencekit-0.2.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,852 @@
|
|
|
1
|
+
"""Golden checks and invalid-input contracts for every public model."""
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import pytest
|
|
5
|
+
|
|
6
|
+
from earthsciencekit import seismology as domain
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_p_wave_speed_reference():
|
|
10
|
+
result = domain.p_wave_speed(*[12, 3, 4])
|
|
11
|
+
np.testing.assert_allclose(result, 2, rtol=1e-11, atol=1e-12)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
15
|
+
def test_p_wave_speed_rejects_invalid(bad):
|
|
16
|
+
args = [12, 3, 4]
|
|
17
|
+
args[0] = bad
|
|
18
|
+
with pytest.raises(ValueError):
|
|
19
|
+
domain.p_wave_speed(*args)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_s_wave_speed_reference():
|
|
23
|
+
result = domain.s_wave_speed(*[16, 4])
|
|
24
|
+
np.testing.assert_allclose(result, 2, rtol=1e-11, atol=1e-12)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
28
|
+
def test_s_wave_speed_rejects_invalid(bad):
|
|
29
|
+
args = [16, 4]
|
|
30
|
+
args[0] = bad
|
|
31
|
+
with pytest.raises(ValueError):
|
|
32
|
+
domain.s_wave_speed(*args)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_poisson_ratio_reference():
|
|
36
|
+
result = domain.poisson_ratio(*[2, 1])
|
|
37
|
+
np.testing.assert_allclose(result, 1 / 3, rtol=1e-11, atol=1e-12)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
41
|
+
def test_poisson_ratio_rejects_invalid(bad):
|
|
42
|
+
args = [2, 1]
|
|
43
|
+
args[0] = bad
|
|
44
|
+
with pytest.raises(ValueError):
|
|
45
|
+
domain.poisson_ratio(*args)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_travel_time_reference():
|
|
49
|
+
result = domain.travel_time(*[3000, 1500])
|
|
50
|
+
np.testing.assert_allclose(result, 2, rtol=1e-11, atol=1e-12)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
54
|
+
def test_travel_time_rejects_invalid(bad):
|
|
55
|
+
args = [3000, 1500]
|
|
56
|
+
args[0] = bad
|
|
57
|
+
with pytest.raises(ValueError):
|
|
58
|
+
domain.travel_time(*args)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def test_seismic_impedance_reference():
|
|
62
|
+
result = domain.seismic_impedance(*[2000, 3000])
|
|
63
|
+
np.testing.assert_allclose(result, 6e6, rtol=1e-11, atol=1e-12)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
67
|
+
def test_seismic_impedance_rejects_invalid(bad):
|
|
68
|
+
args = [2000, 3000]
|
|
69
|
+
args[0] = bad
|
|
70
|
+
with pytest.raises(ValueError):
|
|
71
|
+
domain.seismic_impedance(*args)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_reflection_coefficient_reference():
|
|
75
|
+
result = domain.reflection_coefficient(*[2, 6])
|
|
76
|
+
np.testing.assert_allclose(result, 0.5, rtol=1e-11, atol=1e-12)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
80
|
+
def test_reflection_coefficient_rejects_invalid(bad):
|
|
81
|
+
args = [2, 6]
|
|
82
|
+
args[0] = bad
|
|
83
|
+
with pytest.raises(ValueError):
|
|
84
|
+
domain.reflection_coefficient(*args)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def test_transmission_coefficient_reference():
|
|
88
|
+
result = domain.transmission_coefficient(*[2, 6])
|
|
89
|
+
np.testing.assert_allclose(result, 1.5, rtol=1e-11, atol=1e-12)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
93
|
+
def test_transmission_coefficient_rejects_invalid(bad):
|
|
94
|
+
args = [2, 6]
|
|
95
|
+
args[0] = bad
|
|
96
|
+
with pytest.raises(ValueError):
|
|
97
|
+
domain.transmission_coefficient(*args)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def test_critical_angle_reference():
|
|
101
|
+
result = domain.critical_angle(*[1, 2])
|
|
102
|
+
np.testing.assert_allclose(result, np.pi / 6, rtol=1e-11, atol=1e-12)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
106
|
+
def test_critical_angle_rejects_invalid(bad):
|
|
107
|
+
args = [1, 2]
|
|
108
|
+
args[0] = bad
|
|
109
|
+
with pytest.raises(ValueError):
|
|
110
|
+
domain.critical_angle(*args)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def test_seismic_moment_reference():
|
|
114
|
+
result = domain.seismic_moment(*[30000000000.0, 1000000.0, 1])
|
|
115
|
+
np.testing.assert_allclose(result, 3e16, rtol=1e-11, atol=1e-12)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
119
|
+
def test_seismic_moment_rejects_invalid(bad):
|
|
120
|
+
args = [30000000000.0, 1000000.0, 1]
|
|
121
|
+
args[0] = bad
|
|
122
|
+
with pytest.raises(ValueError):
|
|
123
|
+
domain.seismic_moment(*args)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def test_moment_magnitude_reference():
|
|
127
|
+
result = domain.moment_magnitude(*[1.2589254117941714e18])
|
|
128
|
+
np.testing.assert_allclose(result, 6, rtol=1e-11, atol=1e-12)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
132
|
+
def test_moment_magnitude_rejects_invalid(bad):
|
|
133
|
+
args = [1.2589254117941714e18]
|
|
134
|
+
args[0] = bad
|
|
135
|
+
with pytest.raises(ValueError):
|
|
136
|
+
domain.moment_magnitude(*args)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def test_moment_from_magnitude_reference():
|
|
140
|
+
result = domain.moment_from_magnitude(*[6])
|
|
141
|
+
np.testing.assert_allclose(result, 10**18.1, rtol=1e-11, atol=1e-12)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
145
|
+
def test_moment_from_magnitude_rejects_invalid(bad):
|
|
146
|
+
args = [6]
|
|
147
|
+
args[0] = bad
|
|
148
|
+
with pytest.raises(ValueError):
|
|
149
|
+
domain.moment_from_magnitude(*args)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def test_gutenberg_richter_reference():
|
|
153
|
+
result = domain.gutenberg_richter(*[4, 1, 3])
|
|
154
|
+
np.testing.assert_allclose(result, 10, rtol=1e-11, atol=1e-12)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
158
|
+
def test_gutenberg_richter_rejects_invalid(bad):
|
|
159
|
+
args = [4, 1, 3]
|
|
160
|
+
args[0] = bad
|
|
161
|
+
with pytest.raises(ValueError):
|
|
162
|
+
domain.gutenberg_richter(*args)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def test_omori_rate_reference():
|
|
166
|
+
result = domain.omori_rate(*[10, 1, 1, 1])
|
|
167
|
+
np.testing.assert_allclose(result, 5, rtol=1e-11, atol=1e-12)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
171
|
+
def test_omori_rate_rejects_invalid(bad):
|
|
172
|
+
args = [10, 1, 1, 1]
|
|
173
|
+
args[0] = bad
|
|
174
|
+
with pytest.raises(ValueError):
|
|
175
|
+
domain.omori_rate(*args)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def test_ricker_wavelet_reference():
|
|
179
|
+
result = domain.ricker_wavelet(*[0, 10])
|
|
180
|
+
np.testing.assert_allclose(result, 1, rtol=1e-11, atol=1e-12)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
184
|
+
def test_ricker_wavelet_rejects_invalid(bad):
|
|
185
|
+
args = [0, 10]
|
|
186
|
+
args[0] = bad
|
|
187
|
+
with pytest.raises(ValueError):
|
|
188
|
+
domain.ricker_wavelet(*args)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def test_attenuated_amplitude_reference():
|
|
192
|
+
result = domain.attenuated_amplitude(*[2, 1, 1, np.float64(4.532360141827194)])
|
|
193
|
+
np.testing.assert_allclose(result, 1, rtol=1e-11, atol=1e-12)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
197
|
+
def test_attenuated_amplitude_rejects_invalid(bad):
|
|
198
|
+
args = [2, 1, 1, np.float64(4.532360141827194)]
|
|
199
|
+
args[0] = bad
|
|
200
|
+
with pytest.raises(ValueError):
|
|
201
|
+
domain.attenuated_amplitude(*args)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def test_p_wave_speed_broadcasting():
|
|
205
|
+
args = [12, 3, 4]
|
|
206
|
+
reference = domain.p_wave_speed(*args)
|
|
207
|
+
args[0] = np.full((2, 1), args[0])
|
|
208
|
+
result = domain.p_wave_speed(*args)
|
|
209
|
+
assert result.shape == (2, 1)
|
|
210
|
+
np.testing.assert_allclose(result, reference)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def test_p_wave_speed_bulk_modulus_physical_bound():
|
|
214
|
+
args = [12, 3, 4]
|
|
215
|
+
args[0] = 0
|
|
216
|
+
with pytest.raises(ValueError):
|
|
217
|
+
domain.p_wave_speed(*args)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def test_p_wave_speed_shear_modulus_physical_bound():
|
|
221
|
+
args = [12, 3, 4]
|
|
222
|
+
args[1] = -1
|
|
223
|
+
with pytest.raises(ValueError):
|
|
224
|
+
domain.p_wave_speed(*args)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def test_p_wave_speed_density_physical_bound():
|
|
228
|
+
args = [12, 3, 4]
|
|
229
|
+
args[2] = 0
|
|
230
|
+
with pytest.raises(ValueError):
|
|
231
|
+
domain.p_wave_speed(*args)
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def test_s_wave_speed_broadcasting():
|
|
235
|
+
args = [16, 4]
|
|
236
|
+
reference = domain.s_wave_speed(*args)
|
|
237
|
+
args[0] = np.full((2, 1), args[0])
|
|
238
|
+
result = domain.s_wave_speed(*args)
|
|
239
|
+
assert result.shape == (2, 1)
|
|
240
|
+
np.testing.assert_allclose(result, reference)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def test_s_wave_speed_shear_modulus_physical_bound():
|
|
244
|
+
args = [16, 4]
|
|
245
|
+
args[0] = -1
|
|
246
|
+
with pytest.raises(ValueError):
|
|
247
|
+
domain.s_wave_speed(*args)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def test_s_wave_speed_density_physical_bound():
|
|
251
|
+
args = [16, 4]
|
|
252
|
+
args[1] = 0
|
|
253
|
+
with pytest.raises(ValueError):
|
|
254
|
+
domain.s_wave_speed(*args)
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def test_poisson_ratio_broadcasting():
|
|
258
|
+
args = [2, 1]
|
|
259
|
+
reference = domain.poisson_ratio(*args)
|
|
260
|
+
args[0] = np.full((2, 1), args[0])
|
|
261
|
+
result = domain.poisson_ratio(*args)
|
|
262
|
+
assert result.shape == (2, 1)
|
|
263
|
+
np.testing.assert_allclose(result, reference)
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def test_poisson_ratio_p_speed_physical_bound():
|
|
267
|
+
args = [2, 1]
|
|
268
|
+
args[0] = 0
|
|
269
|
+
with pytest.raises(ValueError):
|
|
270
|
+
domain.poisson_ratio(*args)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def test_poisson_ratio_s_speed_physical_bound():
|
|
274
|
+
args = [2, 1]
|
|
275
|
+
args[1] = 0
|
|
276
|
+
with pytest.raises(ValueError):
|
|
277
|
+
domain.poisson_ratio(*args)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def test_travel_time_broadcasting():
|
|
281
|
+
args = [3000, 1500]
|
|
282
|
+
reference = domain.travel_time(*args)
|
|
283
|
+
args[0] = np.full((2, 1), args[0])
|
|
284
|
+
result = domain.travel_time(*args)
|
|
285
|
+
assert result.shape == (2, 1)
|
|
286
|
+
np.testing.assert_allclose(result, reference)
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def test_travel_time_distance_physical_bound():
|
|
290
|
+
args = [3000, 1500]
|
|
291
|
+
args[0] = -1
|
|
292
|
+
with pytest.raises(ValueError):
|
|
293
|
+
domain.travel_time(*args)
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def test_travel_time_speed_physical_bound():
|
|
297
|
+
args = [3000, 1500]
|
|
298
|
+
args[1] = 0
|
|
299
|
+
with pytest.raises(ValueError):
|
|
300
|
+
domain.travel_time(*args)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def test_seismic_impedance_broadcasting():
|
|
304
|
+
args = [2000, 3000]
|
|
305
|
+
reference = domain.seismic_impedance(*args)
|
|
306
|
+
args[0] = np.full((2, 1), args[0])
|
|
307
|
+
result = domain.seismic_impedance(*args)
|
|
308
|
+
assert result.shape == (2, 1)
|
|
309
|
+
np.testing.assert_allclose(result, reference)
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def test_seismic_impedance_density_physical_bound():
|
|
313
|
+
args = [2000, 3000]
|
|
314
|
+
args[0] = 0
|
|
315
|
+
with pytest.raises(ValueError):
|
|
316
|
+
domain.seismic_impedance(*args)
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def test_seismic_impedance_speed_physical_bound():
|
|
320
|
+
args = [2000, 3000]
|
|
321
|
+
args[1] = 0
|
|
322
|
+
with pytest.raises(ValueError):
|
|
323
|
+
domain.seismic_impedance(*args)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def test_reflection_coefficient_broadcasting():
|
|
327
|
+
args = [2, 6]
|
|
328
|
+
reference = domain.reflection_coefficient(*args)
|
|
329
|
+
args[0] = np.full((2, 1), args[0])
|
|
330
|
+
result = domain.reflection_coefficient(*args)
|
|
331
|
+
assert result.shape == (2, 1)
|
|
332
|
+
np.testing.assert_allclose(result, reference)
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def test_reflection_coefficient_impedance1_physical_bound():
|
|
336
|
+
args = [2, 6]
|
|
337
|
+
args[0] = 0
|
|
338
|
+
with pytest.raises(ValueError):
|
|
339
|
+
domain.reflection_coefficient(*args)
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def test_reflection_coefficient_impedance2_physical_bound():
|
|
343
|
+
args = [2, 6]
|
|
344
|
+
args[1] = 0
|
|
345
|
+
with pytest.raises(ValueError):
|
|
346
|
+
domain.reflection_coefficient(*args)
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
def test_transmission_coefficient_broadcasting():
|
|
350
|
+
args = [2, 6]
|
|
351
|
+
reference = domain.transmission_coefficient(*args)
|
|
352
|
+
args[0] = np.full((2, 1), args[0])
|
|
353
|
+
result = domain.transmission_coefficient(*args)
|
|
354
|
+
assert result.shape == (2, 1)
|
|
355
|
+
np.testing.assert_allclose(result, reference)
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def test_transmission_coefficient_impedance1_physical_bound():
|
|
359
|
+
args = [2, 6]
|
|
360
|
+
args[0] = 0
|
|
361
|
+
with pytest.raises(ValueError):
|
|
362
|
+
domain.transmission_coefficient(*args)
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
def test_transmission_coefficient_impedance2_physical_bound():
|
|
366
|
+
args = [2, 6]
|
|
367
|
+
args[1] = 0
|
|
368
|
+
with pytest.raises(ValueError):
|
|
369
|
+
domain.transmission_coefficient(*args)
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
def test_critical_angle_broadcasting():
|
|
373
|
+
args = [1, 2]
|
|
374
|
+
reference = domain.critical_angle(*args)
|
|
375
|
+
args[0] = np.full((2, 1), args[0])
|
|
376
|
+
result = domain.critical_angle(*args)
|
|
377
|
+
assert result.shape == (2, 1)
|
|
378
|
+
np.testing.assert_allclose(result, reference)
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
def test_critical_angle_speed1_physical_bound():
|
|
382
|
+
args = [1, 2]
|
|
383
|
+
args[0] = 0
|
|
384
|
+
with pytest.raises(ValueError):
|
|
385
|
+
domain.critical_angle(*args)
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
def test_critical_angle_speed2_physical_bound():
|
|
389
|
+
args = [1, 2]
|
|
390
|
+
args[1] = 0
|
|
391
|
+
with pytest.raises(ValueError):
|
|
392
|
+
domain.critical_angle(*args)
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
def test_seismic_moment_broadcasting():
|
|
396
|
+
args = [30000000000.0, 1000000.0, 1]
|
|
397
|
+
reference = domain.seismic_moment(*args)
|
|
398
|
+
args[0] = np.full((2, 1), args[0])
|
|
399
|
+
result = domain.seismic_moment(*args)
|
|
400
|
+
assert result.shape == (2, 1)
|
|
401
|
+
np.testing.assert_allclose(result, reference)
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
def test_seismic_moment_rigidity_physical_bound():
|
|
405
|
+
args = [30000000000.0, 1000000.0, 1]
|
|
406
|
+
args[0] = 0
|
|
407
|
+
with pytest.raises(ValueError):
|
|
408
|
+
domain.seismic_moment(*args)
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
def test_seismic_moment_area_physical_bound():
|
|
412
|
+
args = [30000000000.0, 1000000.0, 1]
|
|
413
|
+
args[1] = 0
|
|
414
|
+
with pytest.raises(ValueError):
|
|
415
|
+
domain.seismic_moment(*args)
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
def test_seismic_moment_slip_physical_bound():
|
|
419
|
+
args = [30000000000.0, 1000000.0, 1]
|
|
420
|
+
args[2] = -1
|
|
421
|
+
with pytest.raises(ValueError):
|
|
422
|
+
domain.seismic_moment(*args)
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
def test_moment_magnitude_broadcasting():
|
|
426
|
+
args = [1.2589254117941714e18]
|
|
427
|
+
reference = domain.moment_magnitude(*args)
|
|
428
|
+
args[0] = np.full((2, 1), args[0])
|
|
429
|
+
result = domain.moment_magnitude(*args)
|
|
430
|
+
assert result.shape == (2, 1)
|
|
431
|
+
np.testing.assert_allclose(result, reference)
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
def test_moment_magnitude_moment_physical_bound():
|
|
435
|
+
args = [1.2589254117941714e18]
|
|
436
|
+
args[0] = 0
|
|
437
|
+
with pytest.raises(ValueError):
|
|
438
|
+
domain.moment_magnitude(*args)
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
def test_moment_from_magnitude_broadcasting():
|
|
442
|
+
args = [6]
|
|
443
|
+
reference = domain.moment_from_magnitude(*args)
|
|
444
|
+
args[0] = np.full((2, 1), args[0])
|
|
445
|
+
result = domain.moment_from_magnitude(*args)
|
|
446
|
+
assert result.shape == (2, 1)
|
|
447
|
+
np.testing.assert_allclose(result, reference)
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
def test_gutenberg_richter_broadcasting():
|
|
451
|
+
args = [4, 1, 3]
|
|
452
|
+
reference = domain.gutenberg_richter(*args)
|
|
453
|
+
args[0] = np.full((2, 1), args[0])
|
|
454
|
+
result = domain.gutenberg_richter(*args)
|
|
455
|
+
assert result.shape == (2, 1)
|
|
456
|
+
np.testing.assert_allclose(result, reference)
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
def test_gutenberg_richter_b_physical_bound():
|
|
460
|
+
args = [4, 1, 3]
|
|
461
|
+
args[1] = 0
|
|
462
|
+
with pytest.raises(ValueError):
|
|
463
|
+
domain.gutenberg_richter(*args)
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
def test_omori_rate_broadcasting():
|
|
467
|
+
args = [10, 1, 1, 1]
|
|
468
|
+
reference = domain.omori_rate(*args)
|
|
469
|
+
args[0] = np.full((2, 1), args[0])
|
|
470
|
+
result = domain.omori_rate(*args)
|
|
471
|
+
assert result.shape == (2, 1)
|
|
472
|
+
np.testing.assert_allclose(result, reference)
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
def test_omori_rate_productivity_physical_bound():
|
|
476
|
+
args = [10, 1, 1, 1]
|
|
477
|
+
args[0] = -1
|
|
478
|
+
with pytest.raises(ValueError):
|
|
479
|
+
domain.omori_rate(*args)
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
def test_omori_rate_offset_physical_bound():
|
|
483
|
+
args = [10, 1, 1, 1]
|
|
484
|
+
args[1] = 0
|
|
485
|
+
with pytest.raises(ValueError):
|
|
486
|
+
domain.omori_rate(*args)
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
def test_omori_rate_exponent_physical_bound():
|
|
490
|
+
args = [10, 1, 1, 1]
|
|
491
|
+
args[2] = 0
|
|
492
|
+
with pytest.raises(ValueError):
|
|
493
|
+
domain.omori_rate(*args)
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
def test_omori_rate_time_physical_bound():
|
|
497
|
+
args = [10, 1, 1, 1]
|
|
498
|
+
args[3] = -1
|
|
499
|
+
with pytest.raises(ValueError):
|
|
500
|
+
domain.omori_rate(*args)
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
def test_ricker_wavelet_broadcasting():
|
|
504
|
+
args = [0, 10]
|
|
505
|
+
reference = domain.ricker_wavelet(*args)
|
|
506
|
+
args[0] = np.full((2, 1), args[0])
|
|
507
|
+
result = domain.ricker_wavelet(*args)
|
|
508
|
+
assert result.shape == (2, 1)
|
|
509
|
+
np.testing.assert_allclose(result, reference)
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
def test_ricker_wavelet_frequency_physical_bound():
|
|
513
|
+
args = [0, 10]
|
|
514
|
+
args[1] = 0
|
|
515
|
+
with pytest.raises(ValueError):
|
|
516
|
+
domain.ricker_wavelet(*args)
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
def test_attenuated_amplitude_broadcasting():
|
|
520
|
+
args = [2, 1, 1, 4.532360141827194]
|
|
521
|
+
reference = domain.attenuated_amplitude(*args)
|
|
522
|
+
args[0] = np.full((2, 1), args[0])
|
|
523
|
+
result = domain.attenuated_amplitude(*args)
|
|
524
|
+
assert result.shape == (2, 1)
|
|
525
|
+
np.testing.assert_allclose(result, reference)
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
def test_attenuated_amplitude_frequency_physical_bound():
|
|
529
|
+
args = [2, 1, 1, 4.532360141827194]
|
|
530
|
+
args[1] = -1
|
|
531
|
+
with pytest.raises(ValueError):
|
|
532
|
+
domain.attenuated_amplitude(*args)
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
def test_attenuated_amplitude_time_physical_bound():
|
|
536
|
+
args = [2, 1, 1, 4.532360141827194]
|
|
537
|
+
args[2] = -1
|
|
538
|
+
with pytest.raises(ValueError):
|
|
539
|
+
domain.attenuated_amplitude(*args)
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
def test_attenuated_amplitude_quality_factor_physical_bound():
|
|
543
|
+
args = [2, 1, 1, 4.532360141827194]
|
|
544
|
+
args[3] = 0
|
|
545
|
+
with pytest.raises(ValueError):
|
|
546
|
+
domain.attenuated_amplitude(*args)
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
def test_rayleigh_wave_speed_reference():
|
|
550
|
+
result = domain.rayleigh_wave_speed(*[1.7320508075688772, 1])
|
|
551
|
+
np.testing.assert_allclose(result, np.sqrt(2 - 2 / np.sqrt(3)), rtol=1e-11, atol=1e-12)
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
555
|
+
def test_rayleigh_wave_speed_rejects_invalid(bad):
|
|
556
|
+
args = [1.7320508075688772, 1]
|
|
557
|
+
args[0] = bad
|
|
558
|
+
with pytest.raises(ValueError):
|
|
559
|
+
domain.rayleigh_wave_speed(*args)
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
def test_rayleigh_wave_speed_broadcasting():
|
|
563
|
+
args = [1.7320508075688772, 1]
|
|
564
|
+
reference = domain.rayleigh_wave_speed(*args)
|
|
565
|
+
args[0] = np.full((2, 1), args[0])
|
|
566
|
+
result = domain.rayleigh_wave_speed(*args)
|
|
567
|
+
assert result.shape == (2, 1)
|
|
568
|
+
np.testing.assert_allclose(result, reference)
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
def test_rayleigh_wave_speed_p_speed_physical_bound():
|
|
572
|
+
args = [1.7320508075688772, 1]
|
|
573
|
+
args[0] = 0
|
|
574
|
+
with pytest.raises(ValueError):
|
|
575
|
+
domain.rayleigh_wave_speed(*args)
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
def test_rayleigh_wave_speed_s_speed_physical_bound():
|
|
579
|
+
args = [1.7320508075688772, 1]
|
|
580
|
+
args[1] = 0
|
|
581
|
+
with pytest.raises(ValueError):
|
|
582
|
+
domain.rayleigh_wave_speed(*args)
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
def test_head_wave_travel_time_reference():
|
|
586
|
+
result = domain.head_wave_travel_time(*[4, 1, 1, 2])
|
|
587
|
+
np.testing.assert_allclose(result, 2 + np.sqrt(3), rtol=1e-11, atol=1e-12)
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
591
|
+
def test_head_wave_travel_time_rejects_invalid(bad):
|
|
592
|
+
args = [4, 1, 1, 2]
|
|
593
|
+
args[0] = bad
|
|
594
|
+
with pytest.raises(ValueError):
|
|
595
|
+
domain.head_wave_travel_time(*args)
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
def test_head_wave_travel_time_broadcasting():
|
|
599
|
+
args = [4, 1, 1, 2]
|
|
600
|
+
reference = domain.head_wave_travel_time(*args)
|
|
601
|
+
args[0] = np.full((2, 1), args[0])
|
|
602
|
+
result = domain.head_wave_travel_time(*args)
|
|
603
|
+
assert result.shape == (2, 1)
|
|
604
|
+
np.testing.assert_allclose(result, reference)
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
def test_head_wave_travel_time_distance_physical_bound():
|
|
608
|
+
args = [4, 1, 1, 2]
|
|
609
|
+
args[0] = -1
|
|
610
|
+
with pytest.raises(ValueError):
|
|
611
|
+
domain.head_wave_travel_time(*args)
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
def test_head_wave_travel_time_thickness_physical_bound():
|
|
615
|
+
args = [4, 1, 1, 2]
|
|
616
|
+
args[1] = 0
|
|
617
|
+
with pytest.raises(ValueError):
|
|
618
|
+
domain.head_wave_travel_time(*args)
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
def test_head_wave_travel_time_speed1_physical_bound():
|
|
622
|
+
args = [4, 1, 1, 2]
|
|
623
|
+
args[2] = 0
|
|
624
|
+
with pytest.raises(ValueError):
|
|
625
|
+
domain.head_wave_travel_time(*args)
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
def test_head_wave_travel_time_speed2_physical_bound():
|
|
629
|
+
args = [4, 1, 1, 2]
|
|
630
|
+
args[3] = 0
|
|
631
|
+
with pytest.raises(ValueError):
|
|
632
|
+
domain.head_wave_travel_time(*args)
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
def test_crossover_distance_reference():
|
|
636
|
+
result = domain.crossover_distance(*[1, 1, 3])
|
|
637
|
+
np.testing.assert_allclose(result, 2 * np.sqrt(2), rtol=1e-11, atol=1e-12)
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
641
|
+
def test_crossover_distance_rejects_invalid(bad):
|
|
642
|
+
args = [1, 1, 3]
|
|
643
|
+
args[0] = bad
|
|
644
|
+
with pytest.raises(ValueError):
|
|
645
|
+
domain.crossover_distance(*args)
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
def test_crossover_distance_broadcasting():
|
|
649
|
+
args = [1, 1, 3]
|
|
650
|
+
reference = domain.crossover_distance(*args)
|
|
651
|
+
args[0] = np.full((2, 1), args[0])
|
|
652
|
+
result = domain.crossover_distance(*args)
|
|
653
|
+
assert result.shape == (2, 1)
|
|
654
|
+
np.testing.assert_allclose(result, reference)
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
def test_crossover_distance_thickness_physical_bound():
|
|
658
|
+
args = [1, 1, 3]
|
|
659
|
+
args[0] = 0
|
|
660
|
+
with pytest.raises(ValueError):
|
|
661
|
+
domain.crossover_distance(*args)
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
def test_crossover_distance_speed1_physical_bound():
|
|
665
|
+
args = [1, 1, 3]
|
|
666
|
+
args[1] = 0
|
|
667
|
+
with pytest.raises(ValueError):
|
|
668
|
+
domain.crossover_distance(*args)
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
def test_crossover_distance_speed2_physical_bound():
|
|
672
|
+
args = [1, 1, 3]
|
|
673
|
+
args[2] = 0
|
|
674
|
+
with pytest.raises(ValueError):
|
|
675
|
+
domain.crossover_distance(*args)
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
def test_love_wave_angular_frequency_reference():
|
|
679
|
+
result = domain.love_wave_angular_frequency(*[1.4142135623730951, 1, 1, 2, 1, 1])
|
|
680
|
+
np.testing.assert_allclose(result, np.sqrt(2) * np.arctan(np.sqrt(0.5)), rtol=1e-11, atol=1e-12)
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
684
|
+
def test_love_wave_angular_frequency_rejects_invalid(bad):
|
|
685
|
+
args = [1.4142135623730951, 1, 1, 2, 1, 1]
|
|
686
|
+
args[0] = bad
|
|
687
|
+
with pytest.raises(ValueError):
|
|
688
|
+
domain.love_wave_angular_frequency(*args)
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
def test_love_wave_angular_frequency_broadcasting():
|
|
692
|
+
args = [1.4142135623730951, 1, 1, 2, 1, 1]
|
|
693
|
+
reference = domain.love_wave_angular_frequency(*args)
|
|
694
|
+
args[0] = np.full((2, 1), args[0])
|
|
695
|
+
result = domain.love_wave_angular_frequency(*args)
|
|
696
|
+
assert result.shape == (2, 1)
|
|
697
|
+
np.testing.assert_allclose(result, reference)
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
def test_love_wave_angular_frequency_phase_speed_physical_bound():
|
|
701
|
+
args = [1.4142135623730951, 1, 1, 2, 1, 1]
|
|
702
|
+
args[0] = 0
|
|
703
|
+
with pytest.raises(ValueError):
|
|
704
|
+
domain.love_wave_angular_frequency(*args)
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
def test_love_wave_angular_frequency_thickness_physical_bound():
|
|
708
|
+
args = [1.4142135623730951, 1, 1, 2, 1, 1]
|
|
709
|
+
args[1] = 0
|
|
710
|
+
with pytest.raises(ValueError):
|
|
711
|
+
domain.love_wave_angular_frequency(*args)
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
def test_love_wave_angular_frequency_layer_s_speed_physical_bound():
|
|
715
|
+
args = [1.4142135623730951, 1, 1, 2, 1, 1]
|
|
716
|
+
args[2] = 0
|
|
717
|
+
with pytest.raises(ValueError):
|
|
718
|
+
domain.love_wave_angular_frequency(*args)
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
def test_love_wave_angular_frequency_halfspace_s_speed_physical_bound():
|
|
722
|
+
args = [1.4142135623730951, 1, 1, 2, 1, 1]
|
|
723
|
+
args[3] = 0
|
|
724
|
+
with pytest.raises(ValueError):
|
|
725
|
+
domain.love_wave_angular_frequency(*args)
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
def test_love_wave_angular_frequency_layer_rigidity_physical_bound():
|
|
729
|
+
args = [1.4142135623730951, 1, 1, 2, 1, 1]
|
|
730
|
+
args[4] = 0
|
|
731
|
+
with pytest.raises(ValueError):
|
|
732
|
+
domain.love_wave_angular_frequency(*args)
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
def test_love_wave_angular_frequency_halfspace_rigidity_physical_bound():
|
|
736
|
+
args = [1.4142135623730951, 1, 1, 2, 1, 1]
|
|
737
|
+
args[5] = 0
|
|
738
|
+
with pytest.raises(ValueError):
|
|
739
|
+
domain.love_wave_angular_frequency(*args)
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
def test_ray_parameter_reference():
|
|
743
|
+
result = domain.ray_parameter(*[2, 4, 0.5235987755982988])
|
|
744
|
+
np.testing.assert_allclose(result, 0.25, rtol=1e-11, atol=1e-12)
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
748
|
+
def test_ray_parameter_rejects_invalid(bad):
|
|
749
|
+
args = [2, 4, 0.5235987755982988]
|
|
750
|
+
args[0] = bad
|
|
751
|
+
with pytest.raises(ValueError):
|
|
752
|
+
domain.ray_parameter(*args)
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
def test_ray_parameter_broadcasting():
|
|
756
|
+
args = [2, 4, 0.5235987755982988]
|
|
757
|
+
reference = domain.ray_parameter(*args)
|
|
758
|
+
args[0] = np.full((2, 1), args[0])
|
|
759
|
+
result = domain.ray_parameter(*args)
|
|
760
|
+
assert result.shape == (2, 1)
|
|
761
|
+
np.testing.assert_allclose(result, reference)
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
def test_ray_parameter_radius_physical_bound():
|
|
765
|
+
args = [2, 4, 0.5235987755982988]
|
|
766
|
+
args[0] = 0
|
|
767
|
+
with pytest.raises(ValueError):
|
|
768
|
+
domain.ray_parameter(*args)
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
def test_ray_parameter_speed_physical_bound():
|
|
772
|
+
args = [2, 4, 0.5235987755982988]
|
|
773
|
+
args[1] = 0
|
|
774
|
+
with pytest.raises(ValueError):
|
|
775
|
+
domain.ray_parameter(*args)
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
def test_ray_parameter_incidence_angle_physical_bound():
|
|
779
|
+
args = [2, 4, 0.5235987755982988]
|
|
780
|
+
args[2] = -1
|
|
781
|
+
with pytest.raises(ValueError):
|
|
782
|
+
domain.ray_parameter(*args)
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
def test_local_magnitude_reference():
|
|
786
|
+
result = domain.local_magnitude(*[1e-3, 1e5])
|
|
787
|
+
np.testing.assert_allclose(result, 3, rtol=1e-11, atol=1e-12)
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
791
|
+
def test_local_magnitude_rejects_invalid(bad):
|
|
792
|
+
args = [1e-3, 1e5]
|
|
793
|
+
args[0] = bad
|
|
794
|
+
with pytest.raises(ValueError):
|
|
795
|
+
domain.local_magnitude(*args)
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
def test_local_magnitude_broadcasting():
|
|
799
|
+
args = [1e-3, 1e5]
|
|
800
|
+
reference = domain.local_magnitude(*args)
|
|
801
|
+
args[0] = np.full((2, 1), args[0])
|
|
802
|
+
result = domain.local_magnitude(*args)
|
|
803
|
+
assert result.shape == (2, 1)
|
|
804
|
+
np.testing.assert_allclose(result, reference)
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
def test_local_magnitude_amplitude_physical_bound():
|
|
808
|
+
args = [1e-3, 1e5]
|
|
809
|
+
args[0] = 0
|
|
810
|
+
with pytest.raises(ValueError):
|
|
811
|
+
domain.local_magnitude(*args)
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
def test_local_magnitude_distance_physical_bound():
|
|
815
|
+
args = [1e-3, 1e5]
|
|
816
|
+
args[1] = 0
|
|
817
|
+
with pytest.raises(ValueError):
|
|
818
|
+
domain.local_magnitude(*args)
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
def test_ray_parameter_incidence_angle_upper_bound():
|
|
822
|
+
with pytest.raises(ValueError):
|
|
823
|
+
domain.ray_parameter(2, 4, 2)
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
def test_vertical_travel_time_reference():
|
|
827
|
+
result = domain.vertical_travel_time(*[[0, 1], [1, np.e]])
|
|
828
|
+
np.testing.assert_allclose(result, [0, 1 / (np.e - 1)], rtol=1e-11, atol=1e-12)
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
@pytest.mark.parametrize("bad", [np.nan, np.inf, -np.inf, [], "bad", True, 1j])
|
|
832
|
+
def test_vertical_travel_time_rejects_invalid(bad):
|
|
833
|
+
args = [[0, 1], [1, np.e]]
|
|
834
|
+
args[0] = bad
|
|
835
|
+
with pytest.raises(ValueError):
|
|
836
|
+
domain.vertical_travel_time(*args)
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
def test_vertical_travel_time_depth_physical_bound():
|
|
840
|
+
with pytest.raises(ValueError):
|
|
841
|
+
domain.vertical_travel_time([-1, 1], [1, 2])
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
def test_vertical_travel_time_speed_physical_bound():
|
|
845
|
+
with pytest.raises(ValueError):
|
|
846
|
+
domain.vertical_travel_time([0, 1], [1, 0])
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
@pytest.mark.parametrize("depth,speed", [([0], [1]), ([[0, 1]], [[1, 2]]), ([0, 1], [1, 2, 3]), ([0, 2, 1], [1, 2, 3])])
|
|
850
|
+
def test_vertical_travel_time_requires_profile(depth, speed):
|
|
851
|
+
with pytest.raises(ValueError):
|
|
852
|
+
domain.vertical_travel_time(depth, speed)
|