Пример #1
0
 def test_rf_deconvf(self):
     N = len(self.Z)
     data1 = self.N * cosTaper(N, 0.1)
     data2 = self.E * cosTaper(N, 0.1)
     src = np.concatenate((self.Z[:N // 10] * cosTaper(N // 10, 0.1), np.zeros(N - N // 10)))
     rf_data = rf.deconvf([data1, data2], src, 100, water=0.01, gauss=2, tshift=10., pad=0)
     self.assertEqual(np.shape(rf_data), (2, N)) # nonesense test
Пример #2
0
def test():
    import pylab as plt
    from sito.stream import read
    from sito.util import cosTaper, get_window
    plt.plot(cosTaper(1000, 0.1))
    plt.plot(get_window(('gaussian', 100), 1000))

    N = 10000
    data = np.concatenate((get_window(
        ('gaussian', 10), N // 4), -2 * get_window(
            ('gaussian', 10), N // 4), get_window(('gaussian', 100),
                                                  N // 4), np.zeros(N // 4)))
    src = np.concatenate((get_window(('gaussian', 10),
                                     N // 10), np.zeros(N * 9 // 10)))

    #deconvfAnalyse(data, src, 100, water=0.1, gauss=10, tshift=10., pad=0) # try gauss=2, 10, 100
    dummy = deconvf(data, src, 100, water=0.01, gauss=2, tshift=10., pad=0)

    ms = read('./tests/data_temp/STREAM.QHD')[0:3]
    deconvfAnalyse(ms[1].data,
                   ms[0].data,
                   100,
                   water=0.01,
                   gauss=2,
                   tshift=10.,
                   pad=0)  # try gauss=2, 10, 100
    plt.show()
Пример #3
0
    def test_util_window(self):
        N = 101
#        from pylab import plot, legend, show
#        plot(util.main.getWindow('tukey', N, 0.8), label='0.8')
#        plot(util.main.getWindow('tukey', N, 0.1), label='0.1')
#        plot(util.cosTaper(N, 0.1), label='cosTaper0.1')
#        plot(util.cosTaper(N, 0.8), label='cosTaper0.8')
#        plot(util.cosTaper(N, 1), label='cosTaper1.0')
#        plot(util.main.getWindow('tukey', N, 1), label='1')
#        plot(util.main.getWindow('hanning', N), label='hanning')
#        legend()
#        show()
        np.testing.assert_array_almost_equal(util.main.getWindow('tukey', N, 0.), util.get_window('boxcar', N))
        np.testing.assert_array_almost_equal(util.main.getWindow('tukey', N, 1.), util.get_window('hanning', N))
        self.assertTrue(np.sum((util.main.getWindow('tukey', N, 0.1) -
                                util.cosTaper(N, 0.1)) ** 2) < 0.2) #cosTaper from Obspy is no normal cosine -> high difference
Пример #4
0
def test():
    import pylab as plt
    from sito.stream import read
    from sito.util import cosTaper, get_window
    plt.plot(cosTaper(1000, 0.1))
    plt.plot(get_window(('gaussian', 100), 1000))

    N = 10000
    data = np.concatenate((get_window(('gaussian', 10), N // 4), -2 * get_window(('gaussian', 10), N // 4), get_window(('gaussian', 100), N // 4), np.zeros(N // 4)))
    src = np.concatenate((get_window(('gaussian', 10), N // 10), np.zeros(N * 9 // 10)))

    #deconvfAnalyse(data, src, 100, water=0.1, gauss=10, tshift=10., pad=0) # try gauss=2, 10, 100
    dummy = deconvf(data, src, 100, water=0.01, gauss=2, tshift=10., pad=0)

    ms = read('./tests/data_temp/STREAM.QHD')[0:3]
    deconvfAnalyse(ms[1].data, ms[0].data, 100, water=0.01, gauss=2, tshift=10., pad=0)  # try gauss=2, 10, 100
    plt.show()
Пример #5
0
 def _window(self, start, end, window='tukey', lenslope=10):
     """
     Window between start and end with args passed to util.getWindow function.
     """
     # if relative != 'ok':
     #    start, end = util.getTimeIntervall(Stream([self]), start, end, relative, ttype='secstart')
     #    start = start[0]
     #    end = end[0]
     t = np.linspace(0, self.stats.endtime - self.stats.starttime, self.stats.npts)
     boolarray = (t >= start) * (t <= end)
     lenwindow = len(boolarray[boolarray])
     alpha = 2. * lenslope / (end - start)  # inserted 1- !!!
     if alpha > 1:
         alpha = 1
     elif alpha < 0:
         alpha = 0
     if window == 'tukey':
         self.data[boolarray] *= util.cosTaper(lenwindow, alpha)
     else:
         self.data[boolarray] *= util.get_window(window, lenwindow)
     self.data[boolarray == False] = 0
Пример #6
0
 def _window(self, start, end, window='tukey', lenslope=10):
     """
     Window between start and end with args passed to util.getWindow function.
     """
     # if relative != 'ok':
     #    start, end = util.getTimeIntervall(Stream([self]), start, end, relative, ttype='secstart')
     #    start = start[0]
     #    end = end[0]
     t = np.linspace(0, self.stats.endtime - self.stats.starttime,
                     self.stats.npts)
     boolarray = (t >= start) * (t <= end)
     lenwindow = len(boolarray[boolarray])
     alpha = 2. * lenslope / (end - start)  # inserted 1- !!!
     if alpha > 1:
         alpha = 1
     elif alpha < 0:
         alpha = 0
     if window == 'tukey':
         self.data[boolarray] *= util.cosTaper(lenwindow, alpha)
     else:
         self.data[boolarray] *= util.get_window(window, lenwindow)
     self.data[boolarray == False] = 0