def test_svd_plot(self): from eqcorrscan.utils.clustering import svd, svd_to_stream uvec, sval, svec, stachans = svd(stream_list=self.stream_list) svstreams = svd_to_stream(uvectors=uvec, stachans=stachans, k=3, sampling_rate=100) fig = svd_plot(svstreams=svstreams, svalues=sval, stachans=stachans, show=False, return_figure=True) return fig[0]
def test_svd_to_stream(self): """Test the conversion of SVD to stream.""" samp_rate = 100 testing_path = os.path.join( self.testing_path, 'similar_events_processed') stream_files = glob.glob(os.path.join(testing_path, '*')) stream_list = [read(stream_file) for stream_file in stream_files] SVectors, SValues, Uvectors, stachans = svd(stream_list=stream_list) svstreams = svd_to_stream(uvectors=SVectors, stachans=stachans, k=4, sampling_rate=samp_rate) self.assertEqual(len(svstreams), 4)
def test_svd_to_stream(self): """Test the conversion of SVD to stream.""" samp_rate = 100 testing_path = os.path.join(self.testing_path, 'similar_events') stream_files = glob.glob(os.path.join(testing_path, '*')) stream_list = [read(stream_file) for stream_file in stream_files] for stream in stream_list: for tr in stream: if tr.stats.station not in ['WHAT2', 'WV04', 'GCSZ']: stream.remove(tr) continue tr.detrend('simple') tr.filter('bandpass', freqmin=5.0, freqmax=15.0) tr.resample(sampling_rate=samp_rate) tr.trim(tr.stats.starttime + 40, tr.stats.endtime - 45) SVectors, SValues, Uvectors, stachans = svd(stream_list=stream_list) svstreams = svd_to_stream(uvectors=SVectors, stachans=stachans, k=4, sampling_rate=samp_rate) self.assertEqual(len(svstreams), 4) with warnings.catch_warnings(record=True) as w: SVD_2_stream(uvectors=SVectors, stachans=stachans, k=4, sampling_rate=samp_rate) self.assertEqual(len(w), 1) self.assertTrue('Depreciated' in str(w[0].message))