[add] tests for picking with missing trace in stream
This commit is contained in:
parent
318ca25ef8
commit
153beff663
@ -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)
|
station = AutopickStation(wfstream, pickparam, verbose, iplot, fig_dict, metadata, origin)
|
||||||
return station.autopickstation()
|
return station.autopickstation()
|
||||||
except MissingTraceException as e:
|
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)
|
print(e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -159,5 +159,21 @@ class TestAutopickStation(unittest.TestCase):
|
|||||||
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
self.assertDictContainsSubset(expected=expected['S'], actual=result['S'])
|
||||||
self.assertEqual(expected['station'], result['station'])
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user