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
|
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
|
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
|
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.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.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]
|
0.05 0.5 #bph1# %lower/upper corner freq. of first band pass filter H-comp. [Hz]
|
||||||
|
@ -41,6 +41,7 @@ local #extent# %extent of a
|
|||||||
10.0 #sstop# %end time [s] after 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
|
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 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 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]
|
2.0 10.0 #bph1# %lower/upper corner freq. of first band pass filter H-comp. [Hz]
|
||||||
|
@ -41,6 +41,7 @@ local #extent# %extent of a
|
|||||||
10.0 #sstop# %end time [s] after 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
|
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 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 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]
|
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
|
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
|
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
|
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.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.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]
|
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
|
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
|
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
|
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.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.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]
|
0.01 0.5 #bph1# %lower/upper corner freq. of first band pass filter H-comp. [Hz]
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
import pytest
|
||||||
|
|
||||||
import obspy
|
import obspy
|
||||||
from obspy import UTCDateTime
|
from obspy import UTCDateTime
|
||||||
@ -105,7 +106,6 @@ class TestAutopickStation(unittest.TestCase):
|
|||||||
# show complete diff when difference in results dictionaries are found
|
# show complete diff when difference in results dictionaries are found
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
|
|
||||||
# @skip("Works")
|
|
||||||
def test_autopickstation_taupy_disabled_gra1(self):
|
def test_autopickstation_taupy_disabled_gra1(self):
|
||||||
expected = {
|
expected = {
|
||||||
'P': {'picker': 'auto', 'snrdb': 15.405649120980094, 'weight': 0, 'Mo': None, 'marked': [], 'Mw': None,
|
'P': {'picker': 'auto', 'snrdb': 15.405649120980094, 'weight': 0, 'Mo': None, 'marked': [], 'Mw': None,
|
||||||
@ -121,8 +121,8 @@ class TestAutopickStation(unittest.TestCase):
|
|||||||
with HidePrints():
|
with HidePrints():
|
||||||
result, station = autopickstation(wfstream=self.gra1, pickparam=self.pickparam_taupy_disabled,
|
result, station = autopickstation(wfstream=self.gra1, pickparam=self.pickparam_taupy_disabled,
|
||||||
metadata=(None, None))
|
metadata=(None, None))
|
||||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
compare_dicts(expected=expected['P'], result=result['P'])
|
||||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
compare_dicts(expected=expected['S'], result=result['S'])
|
||||||
self.assertEqual('GRA1', station)
|
self.assertEqual('GRA1', station)
|
||||||
|
|
||||||
def test_autopickstation_taupy_enabled_gra1(self):
|
def test_autopickstation_taupy_enabled_gra1(self):
|
||||||
@ -140,8 +140,8 @@ class TestAutopickStation(unittest.TestCase):
|
|||||||
with HidePrints():
|
with HidePrints():
|
||||||
result, station = autopickstation(wfstream=self.gra1, pickparam=self.pickparam_taupy_enabled,
|
result, station = autopickstation(wfstream=self.gra1, pickparam=self.pickparam_taupy_enabled,
|
||||||
metadata=self.metadata, origin=self.origin)
|
metadata=self.metadata, origin=self.origin)
|
||||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
compare_dicts(expected=expected['P'], result=result['P'])
|
||||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
compare_dicts(expected=expected['S'], result=result['S'])
|
||||||
self.assertEqual('GRA1', station)
|
self.assertEqual('GRA1', station)
|
||||||
|
|
||||||
def test_autopickstation_taupy_disabled_gra2(self):
|
def test_autopickstation_taupy_disabled_gra2(self):
|
||||||
@ -157,8 +157,8 @@ class TestAutopickStation(unittest.TestCase):
|
|||||||
with HidePrints():
|
with HidePrints():
|
||||||
result, station = autopickstation(wfstream=self.gra2, pickparam=self.pickparam_taupy_disabled,
|
result, station = autopickstation(wfstream=self.gra2, pickparam=self.pickparam_taupy_disabled,
|
||||||
metadata=(None, None))
|
metadata=(None, None))
|
||||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
compare_dicts(expected=expected['P'], result=result['P'])
|
||||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
compare_dicts(expected=expected['S'], result=result['S'])
|
||||||
self.assertEqual('GRA2', station)
|
self.assertEqual('GRA2', station)
|
||||||
|
|
||||||
def test_autopickstation_taupy_enabled_gra2(self):
|
def test_autopickstation_taupy_enabled_gra2(self):
|
||||||
@ -175,8 +175,8 @@ class TestAutopickStation(unittest.TestCase):
|
|||||||
with HidePrints():
|
with HidePrints():
|
||||||
result, station = autopickstation(wfstream=self.gra2, pickparam=self.pickparam_taupy_enabled,
|
result, station = autopickstation(wfstream=self.gra2, pickparam=self.pickparam_taupy_enabled,
|
||||||
metadata=self.metadata, origin=self.origin)
|
metadata=self.metadata, origin=self.origin)
|
||||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
compare_dicts(expected=expected['P'], result=result['P'])
|
||||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
compare_dicts(expected=expected['S'], result=result['S'])
|
||||||
self.assertEqual('GRA2', station)
|
self.assertEqual('GRA2', station)
|
||||||
|
|
||||||
def test_autopickstation_taupy_disabled_ech(self):
|
def test_autopickstation_taupy_disabled_ech(self):
|
||||||
@ -190,8 +190,8 @@ class TestAutopickStation(unittest.TestCase):
|
|||||||
'fm': None, 'spe': None, 'channel': u'LHE'}}
|
'fm': None, 'spe': None, 'channel': u'LHE'}}
|
||||||
with HidePrints():
|
with HidePrints():
|
||||||
result, station = autopickstation(wfstream=self.ech, pickparam=self.pickparam_taupy_disabled)
|
result, station = autopickstation(wfstream=self.ech, pickparam=self.pickparam_taupy_disabled)
|
||||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
compare_dicts(expected=expected['P'], result=result['P'])
|
||||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
compare_dicts(expected=expected['S'], result=result['S'])
|
||||||
self.assertEqual('ECH', station)
|
self.assertEqual('ECH', station)
|
||||||
|
|
||||||
def test_autopickstation_taupy_enabled_ech(self):
|
def test_autopickstation_taupy_enabled_ech(self):
|
||||||
@ -208,8 +208,8 @@ class TestAutopickStation(unittest.TestCase):
|
|||||||
with HidePrints():
|
with HidePrints():
|
||||||
result, station = autopickstation(wfstream=self.ech, pickparam=self.pickparam_taupy_enabled,
|
result, station = autopickstation(wfstream=self.ech, pickparam=self.pickparam_taupy_enabled,
|
||||||
metadata=self.metadata, origin=self.origin)
|
metadata=self.metadata, origin=self.origin)
|
||||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
compare_dicts(expected=expected['P'], result=result['P'])
|
||||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
compare_dicts(expected=expected['S'], result=result['S'])
|
||||||
self.assertEqual('ECH', station)
|
self.assertEqual('ECH', station)
|
||||||
|
|
||||||
def test_autopickstation_taupy_disabled_fiesa(self):
|
def test_autopickstation_taupy_disabled_fiesa(self):
|
||||||
@ -224,8 +224,8 @@ class TestAutopickStation(unittest.TestCase):
|
|||||||
'fm': None, 'spe': None, 'channel': u'LHE'}}
|
'fm': None, 'spe': None, 'channel': u'LHE'}}
|
||||||
with HidePrints():
|
with HidePrints():
|
||||||
result, station = autopickstation(wfstream=self.fiesa, pickparam=self.pickparam_taupy_disabled)
|
result, station = autopickstation(wfstream=self.fiesa, pickparam=self.pickparam_taupy_disabled)
|
||||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
compare_dicts(expected=expected['P'], result=result['P'])
|
||||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
compare_dicts(expected=expected['S'], result=result['S'])
|
||||||
self.assertEqual('FIESA', station)
|
self.assertEqual('FIESA', station)
|
||||||
|
|
||||||
def test_autopickstation_taupy_enabled_fiesa(self):
|
def test_autopickstation_taupy_enabled_fiesa(self):
|
||||||
@ -242,8 +242,8 @@ class TestAutopickStation(unittest.TestCase):
|
|||||||
with HidePrints():
|
with HidePrints():
|
||||||
result, station = autopickstation(wfstream=self.fiesa, pickparam=self.pickparam_taupy_enabled,
|
result, station = autopickstation(wfstream=self.fiesa, pickparam=self.pickparam_taupy_enabled,
|
||||||
metadata=self.metadata, origin=self.origin)
|
metadata=self.metadata, origin=self.origin)
|
||||||
self.assertDictContainsSubset(expected=expected['P'], actual=result['P'])
|
compare_dicts(expected=expected['P'], result=result['P'])
|
||||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
compare_dicts(expected=expected['S'], result=result['S'])
|
||||||
self.assertEqual('FIESA', station)
|
self.assertEqual('FIESA', station)
|
||||||
|
|
||||||
def test_autopickstation_gra1_z_comp_missing(self):
|
def test_autopickstation_gra1_z_comp_missing(self):
|
||||||
@ -272,7 +272,7 @@ class TestAutopickStation(unittest.TestCase):
|
|||||||
with HidePrints():
|
with HidePrints():
|
||||||
result, station = autopickstation(wfstream=wfstream, pickparam=self.pickparam_taupy_disabled,
|
result, station = autopickstation(wfstream=wfstream, pickparam=self.pickparam_taupy_disabled,
|
||||||
metadata=(None, None))
|
metadata=(None, None))
|
||||||
self.assertEqual(expected, result)
|
compare_dicts(result, expected)
|
||||||
self.assertEqual('GRA1', station)
|
self.assertEqual('GRA1', station)
|
||||||
|
|
||||||
def test_autopickstation_a106_taupy_enabled(self):
|
def test_autopickstation_a106_taupy_enabled(self):
|
||||||
@ -290,7 +290,8 @@ class TestAutopickStation(unittest.TestCase):
|
|||||||
with HidePrints():
|
with HidePrints():
|
||||||
result, station = autopickstation(wfstream=self.a106, pickparam=self.pickparam_taupy_enabled,
|
result, station = autopickstation(wfstream=self.a106, pickparam=self.pickparam_taupy_enabled,
|
||||||
metadata=self.metadata, origin=self.origin)
|
metadata=self.metadata, origin=self.origin)
|
||||||
self.assertEqual(expected, result)
|
compare_dicts(result=result, expected=expected)
|
||||||
|
|
||||||
|
|
||||||
def test_autopickstation_station_missing_in_metadata(self):
|
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
|
"""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():
|
with HidePrints():
|
||||||
result, station = autopickstation(wfstream=self.a005a, pickparam=self.pickparam_taupy_enabled,
|
result, station = autopickstation(wfstream=self.a005a, pickparam=self.pickparam_taupy_enabled,
|
||||||
metadata=self.metadata, origin=self.origin)
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user