微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Python scipy.signal 模块-sawtooth() 实例源码

Python scipy.signal 模块,sawtooth() 实例源码

我们从Python开源项目中,提取了以下15代码示例,用于说明如何使用scipy.signal.sawtooth()

项目:cebl    作者:idfah    | 项目源码 | 文件源码
def demoICA():
    t = np.linspace(0.0, 30*np.pi, 1000)

    s1 = spsig.sawtooth(t)
    s2 = np.cos(5.0*t)
    s3 = np.random.uniform(-1.0, 1.0, size=t.size)
    s = np.vstack((s1,s2,s3)).T

    m = np.random.random((3,3))
    m /= m.sum(axis=0)

    sMixed = s.dot(m)

    icaFilt = ICA(sMixed, kurtosis='sub', verbose=True)

    fig = plt.figure()

    axOrig = fig.add_subplot(4,1, 1)
    axOrig.plot(s+util.colsep(s))
    axOrig.set_title('Unmixed Signal')
    axOrig.autoscale(tight=True)

    axMixed = fig.add_subplot(4, 2)
    axMixed.plot(sMixed+util.colsep(sMixed))
    axMixed.set_title('Mixed Signal (random transform)')
    axMixed.autoscale(tight=True)

    axUnmixed = fig.add_subplot(4, 3)
    icaFilt.plottransform(sMixed, ax=axUnmixed)
    axUnmixed.set_title('ICA Components')
    axUnmixed.autoscale(tight=True)

    axCleaned = fig.add_subplot(4, 4)
    icaFilt.plotFilter(sMixed, comp=(0,), ax=axCleaned)
    axCleaned.set_title('Cleaned Signal (First two components kept)')
    axCleaned.autoscale(tight=True)

    fig.tight_layout()
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def demoMSF():
    t = np.linspace(0.0, 1000)

    s1 = spsig.sawtooth(t) #+ 3.0
    s2 = np.cos(5.0*t)
    s3 = np.random.uniform(-1.0,s3)).T

    #m = np.array([ [0.5,0.5,0.0],[0.5,0.0,0.5],[0.0,0.5] ])
    m = np.random.random((3,3))
    m /= m.sum(axis=0)

    sMixed = s.dot(m)

    msfFilt = MSF(sMixed, lags=0)
    fig = plt.figure()

    axOrig = fig.add_subplot(4, 3)
    msfFilt.plottransform(sMixed, ax=axUnmixed)
    axUnmixed.set_title('MSF Components')
    axUnmixed.autoscale(tight=True)

    axCleaned = fig.add_subplot(4, 4)
    msfFilt.plotFilter(sMixed, comp=(2, remove=True, ax=axCleaned)
    axCleaned.set_title('Cleaned Signal (Last Component Removed)')
    axCleaned.autoscale(tight=True)

    fig.tight_layout()
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def __init__(self, mgr, sampRate=128,
                 chans=[str(n)+'x' for n in np.power(2, np.arange(8))/2.0],
                 waveform='sinusoid', freq=1.0, mix='none', pollSize=2):
        """
        Construct a new wave generator source.

        Args:
            sampRate:   Floating point value of the initial sampling frequency.

            chans:      Tuple of strings containing the initial channel
                        configuration.

            waveform:   String describing the type of waveform to produce.
                        May be 'sinusoid' or 'sawtooth' or 'square'

            freq:       Base frequency.  Each channel is a power-of-two
                        multiple of this frequency.

            pollSize:    Number of data samples collected during each poll.
                        Higher values result in better timing and marker
                        resolution but more cpu usage while higher values
                        typically use less cpu but worse timing results.
        """

        self.waveform = mp.Value('I', 0)
        self.freq = mp.Value('d', freq)
        self.t0 = mp.Value('d', 0.0)
        self.t0.value = 0.0
        self.pollSize = pollSize
        self.lock = mp.Lock()

        Source.__init__(self, mgr=mgr, sampRate=sampRate, chans=chans,
            configPanelClass=WaveGenConfigPanel)

        self.setWaveform(waveform)

        self.mixArr = mp.Array('d', self.getNChan()*self.getNChan())
        self.mixMat = (np.frombuffer(self.mixArr.get_obj())
                        .reshape((-1,self.getNChan())))
        self.setMix(mix)
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def setWaveform(self, waveform):
        """Set the periodic waveform to generate.

        Args:
            waveform:   String describing the type of waveform to produce.
                        May be 'sinusoid' or 'sawtooth' or 'square'
        """
        waveform = waveform.lower()

        with self.lock:
            try:
                # index into keys gives us an integer id
                self.waveform.value = list(waveforms.keys()).index(waveform)
            except ValueError:
                raise ValueError('Invalid waveform %s.' % str(waveform))
项目:delayCoupleddplLnet    作者:cuichi23    | 项目源码 | 文件源码
def set_initial(self):                                                      # sets the phase history of the VCO with the frequency of the synchronized state under investigation
        self.d_phi = self.sOmeg * self.dt
        #+ 2.*pi*np.random.normal(loc=0.0,scale=np.sqrt(2.0*self.c)) * np.sqrt(*self.dt) this can be added only if the diffusion constant is normalized such that
        # for changing tau (length of history) the diffusion of phases is the same - i.e. scale by sqrt(tau)
        self.phi = self.phi + self.d_phi
        #print('write history with noise')
        return self.phi, self.d_phi

# y = 1 / n * sum h( x_delayed_neighbours - x_self )
# print('Phasedetector and Combiner: sawtooth')
项目:delayCoupleddplLnet    作者:cuichi23    | 项目源码 | 文件源码
def __init__(self,idx_self,idx_neighbours):
        # print('Phasedetector and Combiner: sawtooth')
        self.h = lambda x: sawtooth(x,width=0.5)                                # set the type of coupling function,here a sawtooth since we consider digital PLLs (rectangular signals)
        self.idx_self = idx_self                                                # assigns the index
        self.idx_neighbours = idx_neighbours                                    # assigns the neighbors according to the coupling topology
        # print('Osci ',idx_self,',my neighbors are:',idx_neighbours)
项目:delayCoupleddplLnet    作者:cuichi23    | 项目源码 | 文件源码
def __init__(self,idx_neighbours):
        # print('Phasedetector and Combiner: sawtooth')
        self.part     = 0.95                                                    # this needs to come from the constructor! add/change... 1params.txt content?!
        self.highHarm = 2.0
        self.h = lambda x: sawtooth(x,width=0.5) + self.part * sawtooth(self.highHarm*x + 0.5*np.pi,width=0.5)  # set the type of coupling function,idx_neighbours)

# y = 1 / n * sum h( x_delayed_neighbours - x_self )
项目:delayCoupleddplLnet    作者:cuichi23    | 项目源码 | 文件源码
def __call__(self, t):
        return signal.sawtooth(2 * np.pi * self.freq * t, width=0.5)
项目:delayCoupleddplLnet    作者:cuichi23    | 项目源码 | 文件源码
def __call__(self, width=0.5)
项目:delayCoupleddplLnet    作者:cuichi23    | 项目源码 | 文件源码
def __call__(self, width=0.5)
项目:delayCoupleddplLnet    作者:cuichi23    | 项目源码 | 文件源码
def __call__(self, width=0.5)
项目:delayCoupleddplLnet    作者:cuichi23    | 项目源码 | 文件源码
def __call__(self, width=0.5)
项目:delayCoupleddplLnet    作者:cuichi23    | 项目源码 | 文件源码
def __call__(self, width=0.5)
项目:delayCoupleddplLnet    作者:cuichi23    | 项目源码 | 文件源码
def __call__(self, width=0.5)
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def demoPCA():
    n = 1000
    t = np.linspace(0.0, n)

    s1 = spsig.sawtooth(t)
    s2 = np.cos(0.5*t)
    #s3 = np.random.normal(scale=1.2,size=t.size)
    s3 = np.random.uniform(-2.0, 2.0,s3)).T

    theta1 = np.pi/6.0
    rot1 = np.array([[np.cos(theta1), -np.sin(theta1), 0.0],
                     [np.sin(theta1),  np.cos(theta1),
                     [0.0,            0.0,           1.0]])

    theta2 = np.pi/4.0
    rot2 = np.array([[ np.cos(theta2), 0.0, np.sin(theta2)],
                     [ 0.0,            1.0,
                     [-np.sin(theta2), np.cos(theta2)]])

    theta3 = np.pi/5.0
    rot3 = np.array([[1.0,             0.0], np.cos(theta3), -np.sin(theta3)], np.sin(theta3),  np.cos(theta3)]])

    sMixed = s.dot(rot1).dot(rot2).dot(rot3)

    lags = 0
    pcaFilt = PCA(sMixed, lags=lags)

    ##pcaFilt.plotMags()

    fig = plt.figure()

    axOrig = fig.add_subplot(4, 2)
    axMixed.plot(sMixed+util.colsep(sMixed))
    axMixed.set_title('Mixed Signal (3d rotation)')
    axMixed.autoscale(tight=True)

    axUnmixed = fig.add_subplot(4, 3)
    pcaFilt.plottransform(sMixed, ax=axUnmixed)
    axUnmixed.set_title('PCA Components')
    axUnmixed.autoscale(tight=True)

    axCleaned = fig.add_subplot(4, 4)
    pcaFilt.plotFilter(sMixed, comp=(1,2, ax=axCleaned)
    axCleaned.set_title('Cleaned Signal (First Component Removed)')
    axCleaned.autoscale(tight=True)

    fig.tight_layout()

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐