本文整理匯總了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()))