示例#1
0
文件: proc.py 项目: Oborichkin/moed
    def _band_filter(size, dt, fc1, fc2):
        lpf_low = Filter.low_pass_filter(size, dt, fc1).y
        lpf_up = Filter.low_pass_filter(size, dt, fc2).y

        for i in range(2 * size + 1):
            if i == size:
                lpf_low[i] = 1 + lpf_low[i] - lpf_up[i]
            else:
                lpf_low[i] = lpf_low[i] - lpf_up[i]
        return Sequence.from_func(range(2 * size + 1), lambda x: lpf_low[x])
示例#2
0
 def gist(seq, intervals=10):
     from collections import defaultdict
     res = defaultdict(int)
     mi = min(seq.y)
     ma = max(seq.y)
     size = (ma - mi) / intervals
     for y in seq.y:
         idx = (y - mi) // size
         res[idx] += 1
     return Sequence.from_func(range(intervals), lambda x: res[x])
示例#3
0
文件: proc.py 项目: Oborichkin/moed
 def high_pass_filter(size, dt, fc):
     lpf = Filter.low_pass_filter(size, dt, fc)
     lpw = lpf.y
     hpf = []
     for i in range(2 * size + 1):
         if i == size:
             hpf.append(1 - lpw[i])
         else:
             hpf.append(-lpw[i])
     return Sequence.from_func(range(2 * size + 1), lambda x: hpf[x])
示例#4
0
 def idft(complex_pairs):
     res = []
     n = len(complex_pairs)
     for k in range(n):
         sum = 0
         for t in range(n):
             angle = (2 * math.pi * k * t) / n
             sum += complex_pairs[t][0] * math.cos(
                 angle) + complex_pairs[t][1] * math.sin(angle)
         res.append(sum)
     return Sequence.from_func(range(n), lambda x: res[x])
示例#5
0
 def convolution(first, second):
     one = first.y
     two = second.y
     n = len(first)
     m = len(second)
     conv = []
     for i in range(n):
         if i in range(n + m):
             res = 0
             for j in range(m):
                 if (i - j) in range(0, n):
                     res += one[i - j] * two[j]
             conv.append(res)
         else:
             conv.append(0)
     return Sequence.from_func(range(n), lambda x: conv[x])
示例#6
0
 def convolve(a, v):
     c = np.convolve(a.y, v.y)
     return Sequence.from_func(range(len(v), len(a)), lambda x: c[x])
示例#7
0
文件: proc.py 项目: Oborichkin/moed
 def low_pass_filter(size, dt, fc):
     half = Filter._half_filter(size, dt, fc)
     result = [*list(reversed(half)), *half[1:]]
     return Sequence.from_func(range(2 * size + 1), lambda x: result[x])
示例#8
0
文件: cardio.py 项目: Oborichkin/moed
 def delta(dots, interval):
     return Sequence.from_func(range(dots), lambda x: 1
                               if x % interval == 0 else 0)
示例#9
0
文件: cardio.py 项目: Oborichkin/moed
 def base(dots, freq, dt, relaxation):
     mult = 2 * math.pi * freq * dt
     return Sequence.from_func(
         range(dots),
         lambda x: math.sin(mult * x) * math.exp(-relaxation * dt * x))