本文整理汇总了Python中scipy.signal.square方法的典型用法代码示例。如果您正苦于以下问题:Python signal.square方法的具体用法?Python signal.square怎么用?Python signal.square使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.signal
的用法示例。
在下文中一共展示了signal.square方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import square [as 别名]
def __init__(self, amplitude, period, timestep, duty=0.5, offset=0,
phase=0):
"""
Constructor.
Args:
amplitude (np.ndarray): amplitude of the square wave;
period (float): time corresponding to one cycle;
timestep (float): time corresponding to each step of simulation;
duty (float, 0.5): value between 0 and 1 and determines the relative
time that the step transition occurs between the start and the
end of the cycle;
offset (float, 0): increment of velocity to each velocity value;
phase (float, 0): angle in rads of the phase of the sine wave.
"""
time_array = np.arange(0, period, timestep)
phase_array = 2 * np.pi * (time_array / period)
phase_array += phase
wave = amplitude * square(phase_array, duty) + offset
super(SquareWaveVelocityProfile, self).__init__(wave, period, timestep)
示例2: _start
# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import square [as 别名]
def _start():
'''Start the module
This uses the global variables from setup and adds a set of global variables
'''
global parser, args, config, r, response, patch, monitor, debug, ft_host, ft_port, ft_output, name
global nchannels, fsample, shape, scale_frequency, scale_amplitude, scale_offset, scale_noise, scale_dutycycle, offset_frequency, offset_amplitude, offset_offset, offset_noise, offset_dutycycle, blocksize, datatype, block, begsample, endsample, stepsize, timevec, phasevec
# get the options from the configuration file
nchannels = patch.getint('generate', 'nchannels')
fsample = patch.getfloat('generate', 'fsample')
# sin, square, triangle, sawtooth or dc
shape = patch.getstring('signal', 'shape')
# the scale and offset are used to map the Redis values to internal values
scale_frequency = patch.getfloat('scale', 'frequency', default=1)
scale_amplitude = patch.getfloat('scale', 'amplitude', default=1)
scale_offset = patch.getfloat('scale', 'offset', default=1)
scale_noise = patch.getfloat('scale', 'noise', default=1)
scale_dutycycle = patch.getfloat('scale', 'dutycycle', default=1)
offset_frequency = patch.getfloat('offset', 'frequency', default=0)
offset_amplitude = patch.getfloat('offset', 'amplitude', default=0)
offset_offset = patch.getfloat('offset', 'offset', default=0)
offset_noise = patch.getfloat('offset', 'noise', default=0)
offset_dutycycle = patch.getfloat('offset', 'dutycycle', default=0)
blocksize = int(round(patch.getfloat('generate', 'window') * fsample))
datatype = 'float32'
if datatype == 'uint8':
ft_output.putHeader(nchannels, fsample, FieldTrip.DATATYPE_UINT8)
elif datatype == 'int8':
ft_output.putHeader(nchannels, fsample, FieldTrip.DATATYPE_INT8)
elif datatype == 'uint16':
ft_output.putHeader(nchannels, fsample, FieldTrip.DATATYPE_UINT16)
elif datatype == 'int16':
ft_output.putHeader(nchannels, fsample, FieldTrip.DATATYPE_INT16)
elif datatype == 'uint32':
ft_output.putHeader(nchannels, fsample, FieldTrip.DATATYPE_UINT32)
elif datatype == 'int32':
ft_output.putHeader(nchannels, fsample, FieldTrip.DATATYPE_INT32)
elif datatype == 'float32':
ft_output.putHeader(nchannels, fsample, FieldTrip.DATATYPE_FLOAT32)
elif datatype == 'float64':
ft_output.putHeader(nchannels, fsample, FieldTrip.DATATYPE_FLOAT64)
monitor.debug("nchannels = " + str(nchannels))
monitor.debug("fsample = " + str(fsample))
monitor.debug("blocksize = " + str(blocksize))
block = 0
begsample = 0
endsample = blocksize - 1
stepsize = blocksize / fsample
# the time axis per block remains the same, the phase linearly increases
timevec = np.arange(1, blocksize + 1) / fsample
phasevec = np.zeros(1)
# there should not be any local variables in this function, they should all be global
if len(locals()):
print("LOCALS: " + ", ".join(locals().keys()))