Ejemplo n.º 1
0
    def testContinuousDownsample(self):

        y = num.random.random(1000)

        for (dt1, dt2) in [(0.1, 1.0), (0.2, 1.0), (0.5, 1.0), (0.2, 0.4),
                           (0.4, 1.2)]:

            for tadd in (0.0, 0.01, 0.2, 0.5, 0.7, 0.75):
                a = trace.Trace(tmin=sometime + tadd, deltat=dt1, ydata=y)
                bs = [
                    trace.Trace(location='b',
                                tmin=sometime + i * dt1 * 100 + tadd,
                                deltat=dt1,
                                ydata=y[i * 100:(i + 1) * 100])
                    for i in range(10)
                ]

                a.downsample_to(dt2, demean=False, snap=True)
                c2s = []
                downsampler = trace.co_downsample_to(trace.co_list_append(c2s),
                                                     dt2)

                for b in bs:
                    c = downsampler.send(b)
                    c2s.append(c)

                downsampler.close()
                assert (round(c2s[0].tmin / dt2) * dt2 - c2s[0].tmin) \
                    / dt1 < 0.5001
Ejemplo n.º 2
0
    def testContinuousDownsample(self):

        y = num.random.random(1000)

        for (dt1, dt2) in [
                (0.1, 1.0),
                (0.2, 1.0),
                (0.5, 1.0),
                (0.2, 0.4),
                (0.4, 1.2)]:

            for tadd in (0.0, 0.01, 0.2, 0.5, 0.7, 0.75):
                a = trace.Trace(tmin=sometime+tadd, deltat=dt1, ydata=y)
                bs = [trace.Trace(
                    location='b',
                    tmin=sometime+i*dt1*100+tadd,
                    deltat=dt1,
                    ydata=y[i*100:(i+1)*100]) for i in range(10)]

                a.downsample_to(dt2, demean=False, snap=True)
                c2s = []
                downsampler = trace.co_downsample_to(
                    trace.co_list_append(c2s), dt2)

                for b in bs:
                    c = downsampler.send(b)
                    c2s.append(c)

                downsampler.close()
                assert (round(c2s[0].tmin / dt2) * dt2 - c2s[0].tmin) \
                    / dt1 < 0.5001
Ejemplo n.º 3
0
 def __init__(self, mapping, deltat):
     Processor.__init__(self)
     self._mapping = mapping
     self._downsampler = tracemod.co_downsample_to(deltat)
Ejemplo n.º 4
0
 def __init__(self, mapping, deltat):
     Processor.__init__(self)
     self._mapping = mapping
     self._downsampler = tracemod.co_downsample_to(deltat)