Compare commits
3 Commits
d0fbb91ffe
...
431dbe8924
Author | SHA1 | Date | |
---|---|---|---|
431dbe8924 | |||
63810730e5 | |||
f2159c47f9 |
@ -41,6 +41,7 @@ global #extent# %extent of a
|
||||
1150.0 #sstop# %end time [s] after P-onset for calculating CF for S-picking
|
||||
True #use_taup# %use estimated traveltimes from TauPy for calculating windows for CF
|
||||
iasp91 #taup_model# %define TauPy model for traveltime estimation. Possible values: 1066a, 1066b, ak135, ak135f, herrin, iasp91, jb, prem, pwdk, sp6
|
||||
P,Pdiff #taup_phases# %Specify possible phases for TauPy (comma separated). See Obspy TauPy documentation for possible values.
|
||||
0.05 0.5 #bpz1# %lower/upper corner freq. of first band pass filter Z-comp. [Hz]
|
||||
0.001 0.5 #bpz2# %lower/upper corner freq. of second band pass filter Z-comp. [Hz]
|
||||
0.05 0.5 #bph1# %lower/upper corner freq. of first band pass filter H-comp. [Hz]
|
||||
|
@ -40,7 +40,8 @@ local #extent# %extent of a
|
||||
-0.5 #sstart# %start time [s] relative to P-onset for calculating CF for S-picking
|
||||
10.0 #sstop# %end time [s] after P-onset for calculating CF for S-picking
|
||||
False #use_taup# %use estimated traveltimes from TauPy for calculating windows for CF
|
||||
iasp91 #taup_model# %define TauPy model for traveltime estimation
|
||||
iasp91 #taup_model# %define TauPy model for traveltime estimation
|
||||
P #taup_phases# %Specify possible phases for TauPy (comma separated). See Obspy TauPy documentation for possible values.
|
||||
2.0 20.0 #bpz1# %lower/upper corner freq. of first band pass filter Z-comp. [Hz]
|
||||
2.0 30.0 #bpz2# %lower/upper corner freq. of second band pass filter Z-comp. [Hz]
|
||||
2.0 10.0 #bph1# %lower/upper corner freq. of first band pass filter H-comp. [Hz]
|
||||
|
@ -40,7 +40,8 @@ local #extent# %extent of a
|
||||
-1.0 #sstart# %start time [s] relative to P-onset for calculating CF for S-picking
|
||||
10.0 #sstop# %end time [s] after P-onset for calculating CF for S-picking
|
||||
True #use_taup# %use estimated traveltimes from TauPy for calculating windows for CF
|
||||
iasp91 #taup_model# %define TauPy model for traveltime estimation
|
||||
iasp91 #taup_model# %define TauPy model for traveltime estimation
|
||||
P #taup_phases# %Specify possible phases for TauPy (comma separated). See Obspy TauPy documentation for possible values.
|
||||
2.0 10.0 #bpz1# %lower/upper corner freq. of first band pass filter Z-comp. [Hz]
|
||||
2.0 12.0 #bpz2# %lower/upper corner freq. of second band pass filter Z-comp. [Hz]
|
||||
2.0 8.0 #bph1# %lower/upper corner freq. of first band pass filter H-comp. [Hz]
|
||||
|
@ -41,6 +41,7 @@ global #extent# %extent of a
|
||||
875.0 #sstop# %end time [s] after P-onset for calculating CF for S-picking
|
||||
False #use_taup# %use estimated traveltimes from TauPy for calculating windows for CF
|
||||
IASP91 #taup_model# %define TauPy model for traveltime estimation. Possible values: 1066a, 1066b, ak135, ak135f, herrin, iasp91, jb, prem, pwdk, sp6
|
||||
P,Pdiff,S,Sdiff #taup_phases# %Specify possible phases for TauPy (comma separated). See Obspy TauPy documentation for possible values.
|
||||
0.01 0.1 #bpz1# %lower/upper corner freq. of first band pass filter Z-comp. [Hz]
|
||||
0.001 0.5 #bpz2# %lower/upper corner freq. of second band pass filter Z-comp. [Hz]
|
||||
0.01 0.5 #bph1# %lower/upper corner freq. of first band pass filter H-comp. [Hz]
|
||||
|
@ -41,6 +41,7 @@ global #extent# %extent of a
|
||||
875.0 #sstop# %end time [s] after P-onset for calculating CF for S-picking
|
||||
True #use_taup# %use estimated traveltimes from TauPy for calculating windows for CF
|
||||
IASP91 #taup_model# %define TauPy model for traveltime estimation. Possible values: 1066a, 1066b, ak135, ak135f, herrin, iasp91, jb, prem, pwdk, sp6
|
||||
P,Pdiff,S,Sdiff #taup_phases# %Specify possible phases for TauPy (comma separated). See Obspy TauPy documentation for possible values.
|
||||
0.01 0.1 #bpz1# %lower/upper corner freq. of first band pass filter Z-comp. [Hz]
|
||||
0.001 0.5 #bpz2# %lower/upper corner freq. of second band pass filter Z-comp. [Hz]
|
||||
0.01 0.5 #bph1# %lower/upper corner freq. of first band pass filter H-comp. [Hz]
|
||||
|
@ -1,6 +1,7 @@
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
import pytest
|
||||
|
||||
import obspy
|
||||
from obspy import UTCDateTime
|
||||
@ -105,7 +106,6 @@ class TestAutopickStation(unittest.TestCase):
|
||||
# show complete diff when difference in results dictionaries are found
|
||||
self.maxDiff = None
|
||||
|
||||
# @skip("Works")
|
||||
def test_autopickstation_taupy_disabled_gra1(self):
|
||||
expected = {
|
||||
'P': {'picker': 'auto', 'snrdb': 15.405649120980094, 'weight': 0, 'Mo': None, 'marked': [], 'Mw': None,
|
||||
@ -121,8 +121,8 @@ class TestAutopickStation(unittest.TestCase):
|
||||
with HidePrints():
|
||||
result, station = autopickstation(wfstream=self.gra1, pickparam=self.pickparam_taupy_disabled,
|
||||
metadata=(None, None))
|
||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
||||
compare_dicts(expected=expected['P'], result=result['P'])
|
||||
compare_dicts(expected=expected['S'], result=result['S'])
|
||||
self.assertEqual('GRA1', station)
|
||||
|
||||
def test_autopickstation_taupy_enabled_gra1(self):
|
||||
@ -140,8 +140,8 @@ class TestAutopickStation(unittest.TestCase):
|
||||
with HidePrints():
|
||||
result, station = autopickstation(wfstream=self.gra1, pickparam=self.pickparam_taupy_enabled,
|
||||
metadata=self.metadata, origin=self.origin)
|
||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
||||
compare_dicts(expected=expected['P'], result=result['P'])
|
||||
compare_dicts(expected=expected['S'], result=result['S'])
|
||||
self.assertEqual('GRA1', station)
|
||||
|
||||
def test_autopickstation_taupy_disabled_gra2(self):
|
||||
@ -157,8 +157,8 @@ class TestAutopickStation(unittest.TestCase):
|
||||
with HidePrints():
|
||||
result, station = autopickstation(wfstream=self.gra2, pickparam=self.pickparam_taupy_disabled,
|
||||
metadata=(None, None))
|
||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
||||
compare_dicts(expected=expected['P'], result=result['P'])
|
||||
compare_dicts(expected=expected['S'], result=result['S'])
|
||||
self.assertEqual('GRA2', station)
|
||||
|
||||
def test_autopickstation_taupy_enabled_gra2(self):
|
||||
@ -175,8 +175,8 @@ class TestAutopickStation(unittest.TestCase):
|
||||
with HidePrints():
|
||||
result, station = autopickstation(wfstream=self.gra2, pickparam=self.pickparam_taupy_enabled,
|
||||
metadata=self.metadata, origin=self.origin)
|
||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
||||
compare_dicts(expected=expected['P'], result=result['P'])
|
||||
compare_dicts(expected=expected['S'], result=result['S'])
|
||||
self.assertEqual('GRA2', station)
|
||||
|
||||
def test_autopickstation_taupy_disabled_ech(self):
|
||||
@ -190,8 +190,8 @@ class TestAutopickStation(unittest.TestCase):
|
||||
'fm': None, 'spe': None, 'channel': u'LHE'}}
|
||||
with HidePrints():
|
||||
result, station = autopickstation(wfstream=self.ech, pickparam=self.pickparam_taupy_disabled)
|
||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
||||
compare_dicts(expected=expected['P'], result=result['P'])
|
||||
compare_dicts(expected=expected['S'], result=result['S'])
|
||||
self.assertEqual('ECH', station)
|
||||
|
||||
def test_autopickstation_taupy_enabled_ech(self):
|
||||
@ -208,8 +208,8 @@ class TestAutopickStation(unittest.TestCase):
|
||||
with HidePrints():
|
||||
result, station = autopickstation(wfstream=self.ech, pickparam=self.pickparam_taupy_enabled,
|
||||
metadata=self.metadata, origin=self.origin)
|
||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
||||
compare_dicts(expected=expected['P'], result=result['P'])
|
||||
compare_dicts(expected=expected['S'], result=result['S'])
|
||||
self.assertEqual('ECH', station)
|
||||
|
||||
def test_autopickstation_taupy_disabled_fiesa(self):
|
||||
@ -224,8 +224,8 @@ class TestAutopickStation(unittest.TestCase):
|
||||
'fm': None, 'spe': None, 'channel': u'LHE'}}
|
||||
with HidePrints():
|
||||
result, station = autopickstation(wfstream=self.fiesa, pickparam=self.pickparam_taupy_disabled)
|
||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
||||
compare_dicts(expected=expected['P'], result=result['P'])
|
||||
compare_dicts(expected=expected['S'], result=result['S'])
|
||||
self.assertEqual('FIESA', station)
|
||||
|
||||
def test_autopickstation_taupy_enabled_fiesa(self):
|
||||
@ -242,8 +242,8 @@ class TestAutopickStation(unittest.TestCase):
|
||||
with HidePrints():
|
||||
result, station = autopickstation(wfstream=self.fiesa, pickparam=self.pickparam_taupy_enabled,
|
||||
metadata=self.metadata, origin=self.origin)
|
||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
||||
compare_dicts(expected=expected['P'], result=result['P'])
|
||||
compare_dicts(expected=expected['S'], result=result['S'])
|
||||
self.assertEqual('FIESA', station)
|
||||
|
||||
def test_autopickstation_gra1_z_comp_missing(self):
|
||||
@ -272,7 +272,7 @@ class TestAutopickStation(unittest.TestCase):
|
||||
with HidePrints():
|
||||
result, station = autopickstation(wfstream=wfstream, pickparam=self.pickparam_taupy_disabled,
|
||||
metadata=(None, None))
|
||||
self.assertEqual(expected, result)
|
||||
compare_dicts(result, expected)
|
||||
self.assertEqual('GRA1', station)
|
||||
|
||||
def test_autopickstation_a106_taupy_enabled(self):
|
||||
@ -290,7 +290,8 @@ class TestAutopickStation(unittest.TestCase):
|
||||
with HidePrints():
|
||||
result, station = autopickstation(wfstream=self.a106, pickparam=self.pickparam_taupy_enabled,
|
||||
metadata=self.metadata, origin=self.origin)
|
||||
self.assertEqual(expected, result)
|
||||
compare_dicts(result=result, expected=expected)
|
||||
|
||||
|
||||
def test_autopickstation_station_missing_in_metadata(self):
|
||||
"""This station is not in the metadata, but Taupy is enabled. Taupy should exit cleanly and modify the starttime
|
||||
@ -311,8 +312,36 @@ class TestAutopickStation(unittest.TestCase):
|
||||
with HidePrints():
|
||||
result, station = autopickstation(wfstream=self.a005a, pickparam=self.pickparam_taupy_enabled,
|
||||
metadata=self.metadata, origin=self.origin)
|
||||
self.assertEqual(expected, result)
|
||||
compare_dicts(result, expected)
|
||||
|
||||
|
||||
def run_dict_comparison(result, expected):
|
||||
for key, expected_value in expected.items():
|
||||
if isinstance(expected_value, dict):
|
||||
run_dict_comparison(result[key], expected[key])
|
||||
else:
|
||||
res = result[key]
|
||||
if isinstance(res, UTCDateTime) and isinstance(expected_value, UTCDateTime):
|
||||
res = res.timestamp
|
||||
expected_value = expected_value.timestamp
|
||||
assert expected_value == pytest.approx(res), f'{key}: {expected_value} != {res}'
|
||||
|
||||
|
||||
def compare_dicts(result, expected):
|
||||
try:
|
||||
run_dict_comparison(result, expected)
|
||||
except AssertionError:
|
||||
raise AssertionError(f'Dictionaries not equal.'
|
||||
f'\n<<Expected>>: \n\n{pretty_print_dict(expected)}'
|
||||
f'\n<<Result>>: \n{pretty_print_dict(result)}')
|
||||
|
||||
|
||||
def pretty_print_dict(dct):
|
||||
retstr = ''
|
||||
for key, value in sorted(dct.items(), key=lambda x: x[0]):
|
||||
retstr += f"{key} : {value}\n"
|
||||
|
||||
return retstr
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user