当前位置: 首页>>代码示例>>Python>>正文


Python signal.sawtooth方法代码示例

本文整理汇总了Python中scipy.signal.sawtooth方法的典型用法代码示例。如果您正苦于以下问题:Python signal.sawtooth方法的具体用法?Python signal.sawtooth怎么用?Python signal.sawtooth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.signal的用法示例。


在下文中一共展示了signal.sawtooth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _reset_reference

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import sawtooth [as 别名]
def _reset_reference(self):
        # get absolute values of amplitude, frequency and offset
        self._amplitude = self._get_current_value(self._amplitude_range)
        self._frequency = self._get_current_value(self._frequency_range)
        offset_range = np.clip(
            self._offset_range, -self._limit_margin[1] + self._amplitude,  self._limit_margin[1] - self._amplitude
        )
        self._offset = self._get_current_value(offset_range)

        t = np.linspace(0, (self._current_episode_length - 1) * self._physical_system.tau, self._current_episode_length)
        phase = np.random.rand() * 2 * np.pi  # note: in the scipy implementation of sawtooth() 1 time-period
        # corresponds to a phase of 2pi
        ref_width = np.random.rand()  # a random value between 0,1 that creates asymmetry in the triangular reference
        # wave ref_width=1 creates a sawtooth waveform
        self._reference = self._amplitude * sg.sawtooth(2*np.pi * self._frequency * t + phase, ref_width) + self._offset
        self._reference = np.clip(self._reference, self._limit_margin[0], self._limit_margin[1]) 
开发者ID:upb-lea,项目名称:gym-electric-motor,代码行数:18,代码来源:triangle_reference_generator.py

示例2: _reset_reference

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import sawtooth [as 别名]
def _reset_reference(self):
        # get absolute values of amplitude, frequency and offset
        self._amplitude = self._get_current_value(self._amplitude_range)
        self._frequency = self._get_current_value(self._frequency_range)
        offset_range = np.clip(self._offset_range, -self._limit_margin[1] + self._amplitude,
                               self._limit_margin[1] - self._amplitude)
        self._offset = self._get_current_value(offset_range)

        t = np.linspace(0, (self._current_episode_length - 1) * self._physical_system.tau, self._current_episode_length)
        phase = np.random.rand() * 2 * np.pi
        # note: in the scipy implementation of sawtooth() 1 time-period corresponds to a phase of 2pi
        self._reference = self._amplitude * sg.sawtooth(2 * np.pi * self._frequency * t + phase) + self._offset
        self._reference = np.clip(self._reference, self._limit_margin[0], self._limit_margin[1]) 
开发者ID:upb-lea,项目名称:gym-electric-motor,代码行数:15,代码来源:sawtooth_reference_generator.py

示例3: _start

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import sawtooth [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())) 
开发者ID:eegsynth,项目名称:eegsynth,代码行数:63,代码来源:generatesignal.py


注:本文中的scipy.signal.sawtooth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。