Archived
Initial commit
This commit is contained in:
commit
d89b82be4a
103 files changed
+23110
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import math
|
||||
import warnings
|
||||
import numpy as np
|
||||
|
||||
|
||||
def cosgate(x, fs, d):
|
||||
if type(d) == 'list':
|
||||
if len(d) == 1:
|
||||
d = np.array([d, d])
|
||||
elif len(d) > 2:
|
||||
raise ValueError(
|
||||
"The ramp duration argument can only be of length 1 or 2.")
|
||||
else:
|
||||
d = np.array([d])
|
||||
|
||||
d = d * fs
|
||||
|
||||
# Onset
|
||||
|
||||
k = np.array(range(0, int(d[0]-1)))
|
||||
# if np.size(x, 2) == 1:
|
||||
# k = k.T
|
||||
|
||||
x[[k+1]] = np.multiply(x[[k+1]], 1 -
|
||||
(1 + np.cos(k * np.pi / (d[0]-1)) / 2))
|
||||
|
||||
# Offset
|
||||
try:
|
||||
k = np.array(range(0, int(d[1]-1)))
|
||||
x[[-k]] = np.multiply(x[[-k]], 1 -
|
||||
(1 + np.cos(k * np.pi / (d[1]-1)) / 2))
|
||||
except IndexError:
|
||||
k = np.array(range(0, int(d[0]-1)))
|
||||
x[[-k]] = np.multiply(x[[-k]], 1 -
|
||||
(1 + np.cos(k * np.pi / (d[0]-1)) / 2))
|
||||
# if np.size(x, 2) == 1:
|
||||
# k = k.T
|
||||
y = x
|
||||
|
||||
return y
|
||||
Reference in new issue
Block a user