-
Notifications
You must be signed in to change notification settings - Fork 6
/
syn.py
72 lines (60 loc) · 1.44 KB
/
syn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import numpy as np
import scipy as sp
from scipy import stats
#todo move to ./data
def xs(**kwargs):
return np.linspace(0,1,1e3,dtype='float32')
def sinewave(xs,**kwargs):
nw=kwargs.setdefault('nw',1) #num waves
return np.sin(xs*nw*2*np.pi)
def const(xs,**kwargs):
c=kwargs.setdefault('c',0)
cs=np.empty(len(xs));cs.fill(c)
return cs
def blip(xs,**kwargs):
kwargs.setdefault('scale',.01)
kwargs.setdefault('loc',.8)
d=sp.stats.norm.pdf(xs,**kwargs)
return d/max(d)
def pulse(xs,**kwargs):
w= sinewave(xs,nw=100)\
+blip(xs)*sinewave(xs,nw=300)
return w
def pulsegen(**kwargs):
return np.array(pulse(xs()),dtype='float32')
# #generate an even number of waves in the re
# nts=np.empty((100,len(xs)))
# for i in xrange(len(nts)):
# nts[i]=sinewave(xs,nw=(i+1)*2)
# nts[-1]=const(xs,c=1)
def cyclespike(**kwargs):
e=kwargs.setdefault('every',20)
u=[0]*e
u[-1]=1
u=u*40
u=np.array(u,dtype='float32')
al=.8
ali=int(len(u)*al)
u[ali:ali+5]=.5
return u
def cyclespikereg(**kwargs):
e=kwargs.setdefault('every',20)
u=[0]*e
u[-1]=1
u=u*40
u=np.array(u,dtype='float32')
al=.8
ali=int(len(u)*al)
u[ali+5]=1
return u
def cyclespikelv(**kwargs):
e=kwargs.setdefault('every',20)
u=[0]*e
u[-1]=1
u=u*40
u=np.array(u,dtype='float32')
al=.8
ali=int(len(u)*al/20);
#u[(20)*5-1]=.75
u[(20)*ali-1]=.75
return u