[add] tests for picking with missing trace in stream

This commit is contained in:
Darius Arnold 2018-07-20 13:01:38 +02:00
parent 318ca25ef8
commit 153beff663
2 changed files with 17 additions and 1 deletions

View File

@ -1052,7 +1052,7 @@ def autopickstation(wfstream, pickparam, verbose=False, iplot=0, fig_dict=None,
station = AutopickStation(wfstream, pickparam, verbose, iplot, fig_dict, metadata, origin)
return station.autopickstation()
except MissingTraceException as e:
# Either vertical or both horizontal traces are missing, autopickstation() will return default results
# Either vertical or both horizontal traces are missing
print(e)
return None

View File

@ -159,5 +159,21 @@ class TestAutopickStation(unittest.TestCase):
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
self.assertEqual(expected['station'], result['station'])
def test_autopickstation_gra1_z_comp_missing(self):
"""Picking on a stream without a vertical trace should return None"""
wfstream = self.gra1.copy()
wfstream = wfstream.select(channel='*E') + wfstream.select(channel='*N')
with HidePrints():
result = autopickstation(wfstream=wfstream, pickparam=self.pickparam_taupy_disabled, metadata=(None, None))
self.assertIsNone(result)
def test_autopickstation_gra1_horizontal_comps_missing(self):
"""Picking on a stream without a horizontal traces should return None"""
wfstream = self.gra1.copy()
wfstream = wfstream.select(channel='*Z')
with HidePrints():
result = autopickstation(wfstream=wfstream, pickparam=self.pickparam_taupy_disabled, metadata=(None, None))
self.assertIsNone(result)
if __name__ == '__main__':
unittest.main()