Esempio n. 1
0
    def test_template_gen(self):
        """Test template generation."""
        from eqcorrscan.core.template_gen import from_sac
        import glob
        import os
        import obspy

        samp_rate = 20
        length = 8

        for event in ['2014p611252', 'No_head']:
            test_files = os.path.join(os.path.abspath(os.path.
                                                      dirname(__file__)),
                                      'test_data', 'SAC', event, '*')
            sac_files = glob.glob(test_files)

            # We currently do not support SAC template generation below version
            # 1.0.0 as before this, SACIO did not fill the reference time,
            # which is needed for defining pick times.  This is usually the
            # trace start time, but isn't always...
            if int(obspy.__version__.split('.')[0]) >= 1:
                template = from_sac(sac_files, lowcut=2.0, highcut=8.0,
                                    samp_rate=samp_rate, filt_order=4,
                                    length=length,
                                    swin='all', prepick=0.1, debug=0, plot=False)
                for tr in template:
                    self.assertEqual(len(tr.data), length * samp_rate)
            else:
                with self.assertRaises(NotImplementedError):
                    template = from_sac(sac_files, lowcut=2.0, highcut=8.0,
                                        samp_rate=samp_rate, filt_order=4,
                                        length=length,
                                        swin='all', prepick=0.1, debug=0,
                                        plot=False)
Esempio n. 2
0
    def test_sac_template_gen(self):
        """Test template generation."""
        from eqcorrscan.core.template_gen import from_sac
        import glob
        import os
        import obspy

        samp_rate = 20
        length = 8

        for event in ['2014p611252', 'No_head']:
            test_files = os.path.join(os.path.abspath(os.path.
                                                      dirname(__file__)),
                                      'test_data', 'SAC', event, '*')
            sac_files = glob.glob(test_files)

            # We currently do not support SAC template generation below version
            # 1.0.0 as before this, SACIO did not fill the reference time,
            # which is needed for defining pick times.  This is usually the
            # trace start time, but isn't always...
            if int(obspy.__version__.split('.')[0]) >= 1:
                template = from_sac(sac_files, lowcut=2.0, highcut=8.0,
                                    samp_rate=samp_rate, filt_order=4,
                                    length=length,
                                    swin='all', prepick=0.1, debug=0,
                                    plot=False)
                for tr in template:
                    self.assertEqual(len(tr.data), length * samp_rate)
            else:
                with self.assertRaises(NotImplementedError):
                    template = from_sac(sac_files, lowcut=2.0, highcut=8.0,
                                        samp_rate=samp_rate, filt_order=4,
                                        length=length,
                                        swin='all', prepick=0.1, debug=0,
                                        plot=False)
Esempio n. 3
0
    def test_sac_template_gen(self):
        """Test template generation."""
        samp_rate = 20
        length = 8

        for event in ['2014p611252', 'No_head']:
            test_files = os.path.join(
                os.path.abspath(os.path.dirname(__file__)), 'test_data', 'SAC',
                event, '*')
            # Test with various input types
            filelist = glob.glob(test_files)
            streamlist = [read(f) for f in glob.glob(test_files)]
            stream = read(test_files)
            for sac_files in [filelist, streamlist, stream]:
                templates = from_sac(sac_files,
                                     lowcut=2.0,
                                     highcut=8.0,
                                     samp_rate=samp_rate,
                                     filt_order=4,
                                     length=length,
                                     swin='all',
                                     prepick=0.1,
                                     debug=0,
                                     plot=False)
                self.assertEqual(len(templates), 1)
                template = templates[0]
                self.assertEqual(len(template), len(sactoevent(stream).picks))
                for tr in template:
                    self.assertEqual(len(tr.data), length * samp_rate)